Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you escape characters in JavaScript/jQuery? [duplicate]

Possible Duplicates:
Escape single quotes in jQuery or JavaScript
Escape dynamic strings in JavaScript

How do you assign a string, in this case it's HTML code, to a JavaScript / jQuery variable?

And how do you escape double quotes and single quotes properly?

var html = ""; // <-- HTML goes here
like image 808
Jonas Avatar asked Aug 08 '26 11:08

Jonas


1 Answers

var html = "<head><title>Hello in \"quotes\"<\/title><\/head>"

like image 51
Rodolfo Avatar answered Aug 11 '26 00:08

Rodolfo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!