This is a bit embarrassing scenario but I need solution.
I am using some names as an ID for li HTML element. These names are having special characters in it. using JQuery to grab an Id.
lets say my id usage is
var abc = li[id="someCompany=\"Some Term\""]
if I am calling this as
alert($(abc).parent()[0]); or
alert($(abc).html());
I am getting data and everything is working fine in firefox but not in IE.
My actual id display in application is
<li id="someCompany="Some Term""> xyz </li>
I am replacing it with .replace(/"/gi, “\””)
Please let me know, How to get it work in IE, Thanks in advance
Sorry guys, I need to give more information in my question…
Firstly, I get ID as
var aaa = "someCompany="some Data"";
I am replacing it as
aaa = aaa.replace(/"/gi, "\"").replace(/'/gi, "\'").replace(/&/gi, "\&");
Then,
var abc = aaa.replace(/"/gi, "\\\"").replace(/\:/gi, "\:").replace(/'/gi,"\\\'");
and then my question follows….
When I tried changing the above line to
var abc = aaa.replace(/"/gi, "\"").replace(/\:/gi, "\:").replace(/'/gi,"\'");
everything is fine but I have some names like
var aaa = "someCompany="some's Data""; //In this case I need to handle more special chanracters
Here, .replace(/"/gi, "\\\"") is working fine in Firefox but not in IE. How can I make it work in IE as well, please suggest
try using browser validation, like single quotes and slash in IE and double in FF.