Reputation: 7785
I'm using a function to add an onClick
event to a <div>
, like:
onClick='function(param)
How can I check now if this event is set at all? div.onClick
doesn't do it's job.
EDIT: I tried now this:
if (typeof div.onClick === 'function')
...and this:
if (!typeof div.onClick === 'function')
and both cases are false.
Upvotes: 1
Views: 1660
Reputation: 50109
if (typeof el.onclick == "function") {
// ...
}
Also, make sure your script is placed at the bottom of the page. You can't select elements otherwise.
Upvotes: 2