美文网首页
2019-04-30子节点

2019-04-30子节点

作者: 果冻_4c9b | 来源:发表于2019-04-30 17:44 被阅读0次
<!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>

相关文章

网友评论

      本文标题:2019-04-30子节点

      本文链接:https://www.haomeiwen.com/subject/noovnqtx.html