e.g
<table lsdata="{1:'Ship\x2dTo\x20Location',4:true}">
</table>
It can't use string contains selector document.querySelector("table[lsdata*='Ship\x2d']")
to select DOM like image:
I read below pages but no answer
- javascript - What chars needs escaping in querySelector? - Stack Overflow
- internationalization - Which encoding uses the \x (backslash x) prefix? - Stack Overflow
- javascript - What chars needs escaping in querySelector? - Stack Overflow
CodePudding user response:
You have to escape the \
but in this case \\
didn't seem to work so I tried with \\\\
and it worked:
const item = document.querySelector('table[lsdata*="Ship\\\\x2d"]')
console.log(item)
<table lsdata="{1:'Ship\x2dTo\x20Location',4:true}">
</table>