What properties can I use with event.target?

后端 未结 7 2049
醉酒成梦
醉酒成梦 2020-12-07 07:39

I need to identify elements from which events are fired.

Using event.target gets the respective element.

What properties can I use from there?<

7条回答
  •  青春惊慌失措
    2020-12-07 08:43

    event.target returns the node that was targeted by the function. This means you can do anything you want to do with any other node like one you'd get from document.getElementById

    I'm tried with jQuery

    var _target = e.target;
    console.log(_target.attr('href'));
    

    Return an error :

    .attr not function

    But _target.attributes.href.value was works.

提交回复
热议问题