Reputation: 35
I am trying to link to the second tab in the first paragraph, where it says trip request form. My Site
I have tried
<a href="#tabs-2" onclick="$('#tabs-2').trigger('click');">trip request form</a>
and
<a href="http://www.euroworldvacations.com/contact-testnew.php#tab-2">trip request form</a>
Still it is not going to the second tab. How can i achieve this?
Upvotes: 2
Views: 86
Reputation: 867
you can use active option of jquery tabs as
<div id="tabs">
<ul>
<li><a href="#tabs-1">Nunc tincidunt</a></li>
<li><a href="#tabs-2">Proin dolor</a></li>
<li><a href="#tabs-3">Aenean lacinia</a></li>
</ul>
<div id="tabs-1">
<p>data1</p>
</div>
<div id="tabs-2">
<p>data2</p>
</div>
<div id="tabs-3">
<p>data3</p>
</div>
</div>
in jquery code
$( "#tabs" ).tabs( "option", "active", 1 );//1 is desired tab index and #tabs is tab id
Upvotes: 1
Reputation: 5466
Just do:
<a href onclick="$('#tabs-2').trigger('click');">trip request form</a>
or
<a href onclick="$('#tabs-2').click();">trip request form</a>
Update:
I visited your site , there is no element with id tab-2, what you are doing is sending the data to backend as, href="http://www.euroworldvacations.com/contact-testnew.php?tab=tab2"
now in backend you get value of tab as tab2.
And also there is no element that does this functionality. If you don't want to refresh the page try using Ajax
Syntax:
$.ajax({
url: "contact-testnew.php",
data : encodeURIComponent("tab=tab2"),
success: function(data){
$(body).html(data); /*right now you get whole page as responce to updating body later just get changed data in response and update only that div*/
}
});
Read further about jQuery Ajax here
Upvotes: 1
Reputation: 5162
You are using wrong naming for id. tabs-2 is not valid name. You can try tab2. Then use
<a href="http://www.euroworldvacations.com/contact-testnew.php#tab2">trip request form</a>
I hope this will solve your problem
Upvotes: 0