<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
// 查找子节点
// children()直接子节点
// find()找后代的指定节点 必 须指定参数可以为类元素id
console.log($('#box').children('p:first-child'));
console.log($('#box').find('p').length);
})
</script>
</head>
<body>
<div id="box">
<p>p1</p>
<div id="">
<p>p2</p>
<p>p3</p>
<p>p4</p>
</div>
<p>p5</p>
</div>
</body>
</html>
网友评论