9
I wonder if there’s a way to click on an element by clicking on another place, something like this:
jQuery
$("#button1").click(function(){
$("#button2").click();
});
I tried that and it didn’t work.
Taking the example Ids as real; there are many events attached to the #button2
and I believe the most practical way to fire them when you click the #button1
that’s the way it is, because I can’t internally touch these events or link them to the #button1
.
Have you tried using the function
trigger
? Staying$('#button2').trigger('click');
. Take a look at http://api.jquery.com/trigger/– Wakim
@Would Wakim rather post as an answer? When I posted your comment, it had not yet appeared to me.
– Bacco
@Bacco, I’m not sure if this is the solution. I say this because the
$(...).click
is a shortcut to thetrigger('click')
(http://stackoverflow.com/questions/9666471/jquery-advantages-differences-in-trigger-vs-click). Maybe the problem could be in thebind
of the event (click
vson
).– Wakim
Need not, can leave the answer.
– Wakim