欧美日韩国产一区二区|qovd片|小明个人发布看看|小浪货你夹真紧水又多|老头把我添高潮了A片故|99热久久精品国产一区二区|久久久春色AV

為非IE瀏覽器添加mouseenter,mouseleave事件的實現代碼是什么 解決方法說明

target 指事件源對象,點擊嵌套元素最里層的某元素,該元素就是target 。IE6/7/8對應的是srcElement 。
currentTarget 指添加事件handler的元素本身,如el.addEventListener中el就是currentTarget 。IE6/7/8沒有對應屬性,可在handler內使用this來替代如evt.currentTarget = this 。
relativeTarget 指事件相關的元素,一般用在mouseover,mouseout事件中 。IE6/7/8中對應的是fromElement,toElement 。
mouseenter ,mouseleave IE9中仍然支持,另見 Greg Reimer 的博文 Goodbye mouseover, hello mouseenter。
mouseenter與mouseover區別在于:在元素內部移動時mouseenter不會觸發 。如下




mouseerter與mouseover區別(IE下測試)




1,鼠標在div[id=parent1]內部移動時也會觸發mouseover事件

Child11
Child12




2,鼠標在div[id=parent2]內部移動時也不會觸發mouseenter事件

Child21
Child22





了解了這三個屬性的意義后 , 實現起來就簡單了:

為非IE瀏覽器添加mouseenter,mouseleave事件的實現代碼是什么 解決方法說明

測試代碼:



mouseerter與mouseover區別(IE下測試)


1,鼠標在div[id=parent1]內部移動時也會觸發mouseover事件
Child11
Child12



2,鼠標在div[id=parent2]內部移動時也不會觸發mouseenter事件
Child21
Child22




【為非IE瀏覽器添加mouseenter,mouseleave事件的實現代碼是什么 解決方法說明】

相關經驗推薦