Reputation: 14773
following situation. I'm using a simple jQuery slider, depending on the tab you click on it changes the html content. I have the following classes:
.tab1
.tab2
etc.
What I would like to do is, to simulate a User-Mouse-Click on .tab2
Can you achieve this with jQuery?
Thanks in advance.
Upvotes: 0
Views: 40
Reputation: 388316
use .trigger() to simulate a event manually
$('.tab2').click() //or $('.tab2').trigger('click')
Form the comments
The problem is .tab2
is the li
element, but the click handler seems to be registered to the a
element inside it so try
$('.tab2').find('a').click()
Upvotes: 1
Reputation: 485
Before that, make sure you bind the click event if you click on the element of the ajax response.
Please check http://justprogrammer.com/2013/06/25/jquery-basic-concepts/ for ajax response.
After that, you could use
$('.tab2').click() //or $('.tab2').trigger('click')
I am binding using live method.
$('.tab2').live('click',function(){
alert('here');
})
Upvotes: 0
Reputation: 141
you can use:
$('.tab2').trigger('click');
to simulate a User-Mouse-Click on .tab2
Upvotes: 0