代碼如下:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>demo009基礎事件</title><script type="text/javascript" src="jquery-1.12.4.min.js"></script><style type="text/css">#box1{width: 200px;height: 200px;background: green;position: relative;}#box2{width: 100px;height: 100px;background: red;position: absolute;top: 140px;left: 100px;}</style></head><body><div id="box1"><div id="box2"></div></div><strong></strong><script type="text/javascript">? ? ? ? /*$('#box1').mouseover(function(){? ? ? ? ?$('strong').html(function(index,value){? ? ? ? ?return value+1;? ? ? ? ?});? ? ? ? });*/? ? ? ? $('#box1').mouseenter(function(){? ? ? ? ?$('strong').html(function(index,value){? ? ? ? ?return value+1;? ? ? ? ?});? ? ? ? });</script></body></html>如果不給子元素box定位的話,mouseover()和mouseenter()的區別就是和老師在課中講的一樣,但是如果將子元素進行絕對定位到父元素外面的話,mouseover()和mouseenter()好像就沒有區別,都會產生事件冒泡。
- 1 回答
- 0 關注
- 1554 瀏覽
添加回答
舉報
0/150
提交
取消