TIMEX TIMEX - 1 year ago 206
Javascript Question

How do I add slashes to a string in Javascript?

Just a string. Add \' to it every time there is a single quote.

Answer Source

replace works for the first quote, so you need a tiny regular expression:

str = str.replace(/'/g, "\\'");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download