继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

jQuery事件

喵喵一只汪
关注TA
已关注
手记 315
粉丝 87
获赞 467


事件

click

mouseover

mouseout

focus

blur

清除所有事件:unbind();



代码示例:选择人名,2个ul,点击某一项之后,移动到另外一个ul中。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">    <title>jQuery测试</title>    <style type="text/css">        ul{            list-style-type: none;        }    </style>    <script type="text/javascript" src="js/jquery-1.12.3.js"></script>    <script type="text/javascript">        $(function () {            $('#u1 li').mouseover(function () {                $(this).css('backgroundColor','red').siblings().css('backgroundColor','');            }).click(function () {//                $(this).css('backgroundColor','').unbind().appendTo($('#u2'));//unbind()                $(this).removeAttr('style').unbind('click').appendTo($('#u2'));//unbind('click')//                $(this).removeAttr('style').unbind().appendTo($('#u2'));//removeAttr('style')            });        });    </script></head><body>    <ul id="u1">        <li>AAAAAA</li>        <li>BBBBBB</li>        <li>CCCCCC</li>        <li>DDDDDD</li>        <li>EEEEEE</li>    </ul>    <hr width="95%"/>    <ul id="u2">    </ul></body></html>


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP