jQuery的选择器,在选择body中出现的title标记时,会出现和预期不同的效果,测试代码如下所示。
<html>
<head>
<script src="jquery-1.2.js"></script>
<script>
$(document).ready (
function () {
console.info($("title"));
console.info($("not_title"));
console.info($("div title"));
console.info($("div not_title"));
}
);
</script>
</head>
<body>
<title>a single title tag, can be selected.</title>
<not_title>a single not_title tag, can be selected.</not_title>
<div>
<title>a title tag embeded in div tag, can not be selected.</title>
</div>
<div>
<not_title>a not_title tag embeded in div tag, can be selected.</not_title>
</div>
</body>
</html>
时间: 2025-01-26 22:08:12