Home > Mobile >  Queryselector back slash x2d can't select 'xxx\x2dxxx'
Queryselector back slash x2d can't select 'xxx\x2dxxx'

Time:12-16

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: image

I read below pages but no answer

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>

  • Related