1

I have:

'<textarea data-ng-show="modal.showPreview == 'Source'"  >'

How can I quote the word Source? I tried single quotes but that does not work.

  • 1
    I think you should have a look at this thread http://stackoverflow.com/questions/2004168/javascript-escape-quotes. – cubitouch Jan 04 '14 at 12:32

3 Answers3

2

You can use escaped double quotes:

'<textarea data-ng-show="modal.showPreview == \"Source\"">'
joews
  • 29,767
  • 10
  • 79
  • 91
1

You can escape the double quotes with Backslash (\)

Your code won't work as intended because, as soon as the browser encounters the first double quote, it will think that the string has finished.

You can refer to this: JavaScript Escape Characters

How about this:

'<textarea data-ng-show="modal.showPreview == \"Source\"" >'
Vishal Suthar
  • 17,013
  • 3
  • 59
  • 105
1

You need to use backslash \

'<textarea data-ng-show="modal.showPreview == \"Source\""  >'
Tareq Salah
  • 3,720
  • 4
  • 34
  • 48