<!DOCTYPE html>
<html lang="en">
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script>
$(function () {
alert($(document.getElementById('test(t)')).html());
});
</script>
</head>
<body>
<div id="test(t)">test</div>
</body>
</html>
当DOM id或class包含()=@等字符时JQuery的id或class选择器无法处理,两种方法,一是修改JQ的选择器的正则,明显的侵入,不推荐,另一种做法很简单,用$(document.getElementById('')即可。
转载于:https://my.oschina.net/gudaoxuri/blog/340929