Possible Duplicate:
Detecting support for a given JavaScript event?
having a random HTMLElement el
, is there anyway of knowing whether el
can listen to an particular event type, for example, 'change'?
Possible Duplicate:
Detecting support for a given JavaScript event?
having a random HTMLElement el
, is there anyway of knowing whether el
can listen to an particular event type, for example, 'change'?
you can try checking if el.attributes.onchange
is declared. I'm not sure, however, if dynamic changes to the webpage will be visible in this manner.
Yes, you can check it for a truthy value like this:
if (el.change) {
el.change();
}
If the method exists you will be able to call it like this. You can check for any method in the manor before trying to call it.