问题描述
点击html按钮时,我需要 select 特定于jquery标签的标签功能.我正在使用jquery.1.9.1.js
和jquery-ui-1.10.2.custom.js
文件.我已经实现了以下代码,但对我不起作用.
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>
问题是函数SelectTab
中的语句$('#ui-tabs').tabs('select', 2);
给我错误Microsoft JScript runtime error: no such method 'select' for tabs widget instance
.正常选择选项卡时,单击它们即可正常工作.但是从函数调用完成后,它不起作用.实施中出了什么问题或缺少任何文件?请提出建议.
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.
推荐答案
此版本中没有用于jQuery UI Tabs的select
方法.为了使您的功能正常工作,您需要将代码更改为;
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 );
请阅读 http://api.jqueryui.com/tabs/#option-active 以获得更多信息.
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 );
请查看以下 jsFiddle 的示例,以了解其工作原理.
Check out this little jsFiddle for an example of it working.
这篇关于Microsoft JScript运行时错误:选项卡小部件实例没有这种方法“选择"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!