开发者

JavaScript event object?

I was told that an 'event object' gets passed as a parameter to the function in the program below. What would an example of an 'event object' be? Is it, for example, the <p> element if you clicked on a <p> or <开发者_运维知识库html> if you clicked on <html>, or is the event object the actual 'click'?

document.addEventListener('click', function(e){
console.log(e.target.nodeName);
},false);


It's roughly the actual click. See the thorough MDC documentation for event and MouseEvent. You can get the target element from event.target.


in html code you can use by example:

<input type="text" onchange="show(this)" />

<script>
  show(e) {alert(e.value);}
</script>

best regards!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜