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

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

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <script src="../js/jquery-3.5.1.js"></script>    <script>        //this对象        $(function () {           $("div").click(function () {               $(this).css("color","blue");               //$(this) 等价于 $("div")           });           $("p").click(function () {               $(this).css("color","red");               //$(this) 等价于 $("p")           });        });    </script></head><body>    <div>单击我改变样式,this始终指向触发当前事件的元素</div>    <p>单击我改变样式,this始终指向触发当前事件的元素</p></body></html>

 

上一篇:jQuery练习t248,从0到1
下一篇:jQuery练习t246,从0到1

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2025年04月01日 22时31分50秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章