Blogger Information
Blog 12
fans 0
comment 0
visits 12714
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
jQuery中的on和off事件
留情的博客
Original
890 people have browsed it
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jQuery中的on和off事件</title>
       <script src="https://cdn.bootcss.com/jquery/3.2.1/core.js"></script>    
<style>
 div {
 width: 50px;
 height: 50px;
 background: red;
        }
 </style>
</head>
<body>
<div></div>
<button>点击移除事件</button>
<script>
$('div').on('mouseenter',function () {  //添加鼠标移入事件
 $(this).hide("fast") //隐藏当前元素 div
}).on('mouseleave',function () { //添加鼠标移出事件
 $(this).css({ //添加多种CSS样式
 'border-radius':'20px',  //圆角
 'background':'yellow', 
 'float':'right' //右浮动
 }).show("fast") 
})  //当mosuseenter+mouseleave和hide+show遇到的时候,由于鼠标不可能绝对静止,所以鼠标在div元素上就产生一个动画效果
$('button').click(function () {  //创建button的点击事件
 $('div').off()  //关闭div的所有效果
})
</script>
</body>
</html>


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!