Click On A Button In The Console Doesn't Work
I have a button to change page but when I want to click on it with the console it doesn't work. But with the mouse it works. This is the plunker : http://plnkr.co/edit/shr2xhNHzcYw
Solution 1:
You are using anchors <a>
and not button <button>
.
To fire click on <a>
you need to use the DOM element, jQuery object $()
does not work.
Use,
$('#language_us')[0].click();
.trigger()
or .click()
triggers a click handler defined explicitly. You need the native click event which is the default functionality of an anchor. So you need to use HTMLElement Object.
If you would have wrote :
$('#language_fr').click(function(){
alert('..')
})
The
$('#language_fr').click()
would have fired the alert()
.
Solution 2:
Try this:
$('#language_us').trigger('click');
$('#language_fr').trigger('click');
Or may be try:
$('#language_us').get(0).click();
$('#language_fr').get(0).click();
Solution 3:
Maybe try to change the tag from a
to button
or put a button
tag inside the a
tag and press that.
Post a Comment for "Click On A Button In The Console Doesn't Work"