If I have an id:
#my~~id
Q#1: Is there a way to target it using js/jQuery? Ex:
var myid = $('#my' + ~~ +'id')
Update: The 'duplicate' doesn't address my question about replace as this question isn't about spaces in a id.
If I have an id:
#my~~id
Q#1: Is there a way to target it using js/jQuery? Ex:
var myid = $('#my' + ~~ +'id')
Update: The 'duplicate' doesn't address my question about replace as this question isn't about spaces in a id.
first they need to be string and you need to escape them with \\
as per escaping instructions in jQuery selectors api
$('#my\\~\\~' +variable)
In $
or querySelector
tilde has a special meaning and won't be interpreted as part of the ID. But document.getElementById('my~~id')
would allow you to be more specific. Better yet: change to a different ID, this one is hard to work with.