【发布时间】:2021-12-15 08:43:36
【问题描述】:
例如
<table lsdata="{1:'Ship\x2dTo\x20Location',4:true}">
</table>
它不能使用包含选择器document.querySelector("table[lsdata*='Ship\x2d']")的字符串来选择像图像一样的DOM:
我阅读了以下页面但没有答案
【问题讨论】:
标签: javascript html regex
例如
<table lsdata="{1:'Ship\x2dTo\x20Location',4:true}">
</table>
它不能使用包含选择器document.querySelector("table[lsdata*='Ship\x2d']")的字符串来选择像图像一样的DOM:
我阅读了以下页面但没有答案
【问题讨论】:
标签: javascript html regex
你必须逃避 \ 但在这种情况下 \\ 似乎不起作用所以我尝试使用 \\\\ 并且它起作用了:
const item = document.querySelector('table[lsdata*="Ship\\\\x2d"]')
console.log(item)
<table lsdata="{1:'Ship\x2dTo\x20Location',4:true}">
</table>
【讨论】: