I want to replace the HTML attribute double quote with single quote. For example:
If the input is:
<a onclick="Track("http://www.example.com")">Track Me</a>
The output will be:
<a onclick='Track("http://www.example.com")'>Track Me</a>
Here the onclick="Track("http://www.example.com")" needs to be replaced with onclick='Track("http://www.example.com")' i.e the only change here is onclick="..." is replaced with onclick='...'.
In my case the content is retrieved from an HTML editor whose content needs to be cleaned in client side using JavaScript. The only way I can currently think of is I need to use Regex to replace the onclick double quote attribute with single quote attribute and it should only happen when "Track" function is used in onclick attribute.
I have tried something like: jsFiddle
I am looking for any solution. Any help is highly appreciated.
Thanks.