Reputation: 673
<div onclick="func(this)" onmouseover="func(this)">
is there a way to know which way (by click or mouseover) func()
was called from code above without changing it (the code above)?
Upvotes: 0
Views: 40
Reputation: 961
event.type gives you the event name. For this work in FF you need to pass event as as the input to the method
jsfiddle link here
<div onclick="javascript:func(event,this)" onmouseover="javascript:func(event,this)">
<span>Hi</span>
</div>
Upvotes: 0
Reputation: 59232
Yes. In func()
, you can do:
event.type
but it won't work in FireFox as it isn't exposed to the global scope as opposed to others.
Upvotes: 4