Monkey Raptor

Tuesday, August 26, 2014

How to Escape Double Quote (or Single Quote) Character in JavaScript

Let's
It can be done by putting the backslash \ in front of the character. It can be also implemented for other character.
For example
We wanna inject a quotation-wrapped text for a div element with the id example below:


The JavaScript:



Result


We can also substitute the double quotation with ", and single quotation with ' — without using the backslash.

Let's use the earlier example:
That also applicable for inserting actual HTML element with class or id or other attribute.


Thanks for visiting!
Published on Last modified on
How to Escape Double Quote (or Single Quote) Character in JavaScript
https://monkeyraptor.johanpaul.net/2014/08/how-to-escape-double-quote-or-single.html

No comments

Post a Comment

Tell me what you think...