I have an element with an onclick method.
I would like to activate that method (or: fake a click on this element) within another function.
Is this possible?
I have an element with an onclick method.
I would like to activate that method (or: fake a click on this element) within another function.
Is this possible?
I haven't used jQuery, but IIRC, the first method mentioned doesn't trigger the
onclick
handler.I'd call the associated
onclick
method directly, if you're not using the event details.If you're using JQuery you can do:
Once you have selected an element you can call click()
see: https://developer.mozilla.org/En/DOM/Element.click
I don't remember if this works on IE, but it should. I don't have a windows machine nearby.
Using
javascript
you can triggerclick()
andfocus()
like below exampleFor IE there is fireEvent() method. Don't know if that works for other browsers.