javascript event对象操作

时间:2021-02-18 19:34:26

js代码:

  $(".leads_detail").click(function(e){

             e = e || event;

             var t = e.target || e.srcElement;

             var leads_id = $(this).data('id');

             if (t.id == "leads_track") {

                 window.open("<?=Url::toRoute(['leads-track'])?>" + "?leads_id=" + leads_id);

             } else {

                 window.open("<?=Url::toRoute(['leads-detail'])?>" + "?leads_id=" + leads_id);

             }

         });

javascript [event对象的具体功能是什么]

JS中的event 对象包含哪些东西 event,[实例 详解]

event获得鼠标点击的DOM对象:

 document.onclick=function(e){
var evt = window.event || e;
var _target = evt.srcElement || evt.target;
alert(_target.tagName)
}

_target 为HTML DOM Element 对象,dom 对象的具体方法和属性:

[HTML DOM Element 对象]

参考:JS中的event属性总结  等等