Nesting quotes in JavaScript/HTML

Posted by Ryan Elkins on Stack Overflow See other posts from Stack Overflow or by Ryan Elkins
Published on 2010-06-14T18:22:27Z Indexed on 2010/06/14 18:32 UTC
Read the original article Hit count: 217

Filed under:
|
|

How do you nest quotes in HTML beyond the second level? As far as I know, there are only 2 types of quotes - single(') and double("). I am aware of escaping - you have to escape in the code but it converts the escaped quotes back to regular quotes when it hits the browser. What is the accepted method to get around something like the following?

<p onclick="exampleFunc('<div id="divId"></div>');">Some Text</p>

That code prints to the browser:

');">Some Text

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html