We help IT Professionals succeed at work.

JAVASCRIPT : Handling Single Quotes and Double quotes

badami
badami asked
on
What is the best way to handle single and double quotes.
This causes lot of Javascripts to break if they are not properly escape sequenced.
Comment
Watch Question

Commented:
I put a \ before them when they're part of a string... for some functions, you have to use single quotes in the parens because you have double quotes around the functions
<a href="#" onclick="doSomething('string1','string2')">

But when I set up a string variable, I use the \ before any quotes in the string.
always insert single quotes in double quotes.

Commented:
That won't work if you have mixed quotes in a string variable. Been there, tried that... ;-)
ahosangFinance Systems Developer

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
points to webwoman
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
ahosang
EE Cleanup Volunteer
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange