jQuery练习t285,从0到1
发布日期:2021-05-06 21:14:53 浏览次数:19 分类:原创文章

本文共 954 字,大约阅读时间需要 3 分钟。

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <style type="text/css">        p{            margin: 6px 0;        }    </style>    <script src="../js/jquery-3.5.1.js"></script>    <script>        //查找后代元素        //.children(selector)        $(function () {           $("#wrapper").hover(function () {               $(this).children(".select").css("color","blue");           },function () {               $(this).children(".select").css("color","black");           });        });        /*        在jQuery中,如果要查找当前元素的后代元素(子元素,孙元素),有        3种方法:        .children()        .find()        .contents()        .children()方法来查找当前元素的子元素,不能查找其后代元素。         */    </script></head><body>    <div id="wrapper">        <p>子元素</p>        <p class="select">子元素</p>        <div>            <p>孙元素</p>            <p class="select">孙元素</p>        </div>        <p>子元素</p>        <p class="select">子元素</p>    </div></body></html>

 

上一篇:jQuery练习t286,从0到1
下一篇:jQuery练习t284,从0到1

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2025年04月17日 09时32分19秒