I have to select a div element id with escape characters,
HTML
<div id="abc/def"></div>
Tried these,
$("#abc/def").find('h4').attr('data-val', "test") //didn't work
$("id=[abc/def]").find('h4').attr('data-val', "test") //didn't work
$("#"+escapeSelector("abc/def")).find('h4').attr('data-val',"Test") //didn't work
function escapeSelector(s) {
return s.replace(/(:|\.|\[|\])/g, "\\$1");
}
Error:
Syntax error, unrecognized expression: #abc/def
Where should i make the change to make this work?
jQuery("div[id^=abc]")ORjQuery("#abc\\/def")