Working on my project, I had to construct a string inside with single quotes. It was a small challenge for me. I did not know how to keep single quotes inside the string. Researching the Internet I found the best way to keep single quotes inside the string. Here's an example:
var temp2 = 'onclick = "window.location=\'test.aspx\'; return false;"';
Back-slash in front of the quote keeps the quote inside of the string. Browser will resolve this statements as
onclick = "window.location='test.aspx'; return false;"
No comments:
Post a Comment