In jQuery I can do something like:
$('#example').click();
What is the equivalent in raw Javascript? I have tried the following:
document.getElementById('example').click();
But that doesn’t seem to work. Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I use this in my framework:
argument 1 is the element, the second argument the event, the third (optional) options.
Sorry, i forgot to rewrite some parts:
_.isObject()to(typeof arguments[2]) == 'object'and
_.changeto change and this function is needed:Edit:
In your case it would be
fireEvent(document.getElementById('example'), 'click');