<html>
<head>
<script type="text/javascript" src="jquery-1.5.2.min.js"></script> <script>
$(function() {
alert($(".test").find("p").size());
})
</script></head><body>
<p class="test"><p>123</p></p>
</body>
</html>
为什么弹出的是0呢?
如果把<p>123</p>改成<span>123</span> find("p")改成find("span") 就可以弹出1了。
<head>
<script type="text/javascript" src="jquery-1.5.2.min.js"></script> <script>
$(function() {
alert($("#test").find("div").size());
})
</script></head><body>
<div class="test">
<div>123</div>
</div>
</body>
</html>
是<p>标签不能嵌套吗?
$(document)
p最好不要这样嵌套
用法错误,
<p>遇到<p>就结束了,会开始新的p,不会形成嵌套关系,用firebug看看页面生成的代码就清楚了。