0

My jquery string has special characters as follows.

$(window).load(function() {  
  var text = 'Hi there, I'm 5'5" height';
  alert (text); // out put without ' " signs
});

i want to print same as it is the out put. How to do it? In PHP it does by htmlspecialchars function. Required output is

Hi there, I'm 5'5" height
Geeth Welagedara
  • 614
  • 1
  • 8
  • 24
  • FYI this has nothing to do with jQuery - it's a "problem" you'd have in vanilla JS too as that's how strings are interpreted. – h2ooooooo Mar 22 '16 at 07:03

1 Answers1

1

You need to escape the quotes using \

  var text = 'Hi there, I\'m 5\'5\" height';
  alert (text); // out put without ' " signs
Satpal
  • 132,252
  • 13
  • 159
  • 168