I need select specific tab functionality for the jquery tabs on clicking on the html buttons. I am using jquery.1.9.1.js
and jquery-ui-1.10.2.custom.js
file. I have implemented below code but does not work for me.
<script language="javascript" type="text/javascript">
$("#ui-tabs").tabs();
function SelectTab() { // bind click event to link
$('#ui-tabs').tabs('select', 2); // switch to third tab
return false;
}
</script>
<div id="ui-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">Tab1 content </div>
<div id="tabs-2">Tab2 content </div>
<div id="tabs-3">Tab3 content </div>
</div><a id="next" class="button-style" href="#" onclick="return SelectTab();">Select Tab</a>
The problem is statement $('#ui-tabs').tabs('select', 2);
in function SelectTab
gives me error Microsoft JScript runtime error: no such method 'select' for tabs widget instance
. Normal selection of tabs on clicking on them working fine. But it is not working when done from function call. Whats going wrong in the implementation or is there any file missing? please suggest.
There is no select
method for jQuery UI Tabs in this version. To get your functionality to work you need to change your code to;
$('#ui-tabs').tabs( "option", "active", 2 );
Please read http://api.jqueryui.com/tabs/#option-active for more information on this.
// getter
var active = $( ".selector" ).tabs( "option", "active" );
// setter
$( ".selector" ).tabs( "option", "active", 1 );
Check out this little jsFiddle for an example of it working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With