JS 獲取觸發事件的物件

2021-05-02 04:30:33 字數 346 閱讀 6830

event.srcelement:引發事件的目標物件,常用於onclick事件。

event.fromelement:引發事件的物件源,常用於onmouseout和onmouseover事件。

event.toelement:引發事件後,滑鼠移動到的目標源,常用於onmouseout和onmouseover事件。

onmouseover時,srcelement相當於toelement;

onmouseout時,srcelement相當於fromsrcelement

小示例(相容ff瀏覽器):

如何用js獲取觸發js事件的DOM

如題,如何用js獲取觸發js事件的dom。對於某事件為myfunction event 可以這樣獲取觸發該函式的domfunction myfunction event 附上event屬性 屬性和方法 描述bubbles 返回布林值,指示事件是否是起泡事件型別。cancelable返回布林值,指示事...

js 強制事件觸發

今天 上select上有個onchange事件,我將option的attr設定成selected並沒有讓這一事件觸發,網上尋找到方法 var event document.createevent htmlevents event.initevent change true,true document...

js手動觸發事件

doctype html en utf 8 js手動觸發事件 title window.onload function downloadevt.initevent click true false oa.dispatchevent downloadevt else if document.creat...