6

Possible Duplicate:
How can I trigger a JavaScript event click

I am developing a website, i want to trigger a mouse click event to a button using java script. please can any one help me solve this problem.

thanks in advance

0

3 Answers 3

9
document.getElementById('your_button').click();
Sign up to request clarification or add additional context in comments.

7 Comments

This is not cross-browser compatible. Afaik this only works in Firefox.
element.onclick(); is cross browser afaiks.
thanks for your reply Felix Kling. the above script is to trigger button click event not mouse click event..
@Arun: Well, the click event triggers the click event handler. Calling the handler is sufficient in most of the cases. If you need something else you have to more specific.
onclick does not work for me in latest version of Chrome
|
2

document.getElementById("id of button").onclick();

Comments

1
document.getElementById("theButton").onclick();

Here is an example fiddle.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.