jquery鼠标移入移出

 

 1 <script type="text/javascript">
 2     $(function(){
 3         /*进入子元素也触发*/
 4         /*$('#div1').mouseover(function() {
 5             $(this).animate({marginTop: 50});//.stop()
 6         });
 7         $('#div1').mouseout(function() {
 8             $(this).animate({marginTop: 100});//.stop()
 9         });*/
10 
11         /*进入子元素不触发*/
12         /*$('#div1').mouseenter(function() {
13             $(this).stop().animate({marginTop: 50});//
14         });
15         $('#div1').mouseleave(function() {
16             $(this).stop().animate({marginTop: 100});//
17         });*/
18 
19         /*通过hover(mouseenter+mouseleave)实现简写*/
20         $('#div1').hover(function() {
21             $(this).stop().animate({marginTop: 50});
22         }, function() {
23             $(this).stop().animate({marginTop: 100});
24         });
25     })
26 </script>

 

posted @ 2021-08-06 14:52  赵瑛  阅读(384)  评论(0编辑  收藏  举报

版权所有 © 2022 沅来是澧

如果有程序开发、网站建设等需求的请联系我,QQ:47419233