I know there are a lot of threads about using meta-character in jQuery selector, but I promise this is unique. I've an html div element with meta-character in its id. Like below,
<body>
<div id="div2$"><h2>Click ME</h2></div>
<button>Load JQuery</button>
</body>
On clicking the button, I'm calling jQuery Load and invoking an AJAX call.
$("#div2\\$").load("something happens here");
No problem upto this. Just works fine.
But when I replace the selector id with a javascript literal, like below, it wouldn't work. So far I've tried
var metaname = "#div2\\\\$";
$(metaname).load("something happens here");
or
var metaname = "#div2\\$";
$(metaname).load("something happens here");
or
var metaname = "\x22"+"#div2\\\\$"+"\x22";
$(metaname).load("something happens here");
or
var metaname = "\x22"+"#div2\\$"+"\x22";
$(metaname).load("something happens here");
Any idea how can I escape a meta-character and assign it to a javascript literal and then use that literal in selector?