代碼如下:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>demo009基礎(chǔ)事件</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()的區(qū)別就是和老師在課中講的一樣,但是如果將子元素進(jìn)行絕對(duì)定位到父元素外面的話,mouseover()和mouseenter()好像就沒有區(qū)別,都會(huì)產(chǎn)生事件冒泡。
1 回答

weibo_哆啦A夢有大口袋_0
TA貢獻(xiàn)107條經(jīng)驗(yàn) 獲得超146個(gè)贊
雖然我也不太懂,建議你去課程問答提問,在你學(xué)習(xí)課程下面問答模塊中提問。
或者你告訴我們,你的問題出自哪門課程的哪一小節(jié)
- 1 回答
- 0 關(guān)注
- 1549 瀏覽
添加回答
舉報(bào)
0/150
提交
取消