我有像
这样的元素<div id = "node-1-@" >
<div class="region">
accessData
</div>
</div>
JavaScript
var data = $("#node-1-@ .region");
console.log(data.html())
这会产生类似的错误
Syntax error, unrecognized expression: #node-1-@
最佳答案
尝试 var data = $("#node-1-\\@ .region");
To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\ .
关于javascript - 如何在jquery中访问id attr中的特殊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44625725/