jQuery idTabs插件选项卡单击功能 [英] jQuery idTabs plugin tab click function
本文介绍了jQuery idTabs插件选项卡单击功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用idTabs jQuery插件时,如何添加单击选项卡时调用的函数?该文档说明了这一点(但未给出示例):
When using the idTabs jQuery plugin how do you add function that is called when a tab is clicked? The documentation says this (but gives no example):
click (function)
Function will be called when a tab is clicked. ex: $(...).idTabs(foo)
If the function returns true, idTabs will show/hide content (as usual).
If the function returns false, idTabs will not take any action.
The function is passed four variables:
The id of the element to be shown
an array of all id's that can be shown
the element containing the tabs
and the current settings
我的代码:
<ul class="idTabs">
<li><a href="#jquery">jQuery</a></li>
<li><a href="#official">Tabs 3</a></li>
</ul>
<div id="jquery">If you haven't checked out ...</div>
<div id="official">idTabs is only a simple ...</div>
function tabChanged(id, tabs, parent, settings) {
alert('tabChanged');
return true;
}
$(".idTabs").idTabs(tabChanged);
单击选项卡没有任何反应-我希望看到一条警报消息
Nothing happens when the tab is clicked - I would expect to seen an alert message
推荐答案
您快到了.您可以这样做:
You are almost there. You can do it like:
$(".idTabs").idTabs({click: tabChanged});
或者您可以使用匿名函数:
Or you can use an anonymous function:
$('.idTabs').idTabs({
click: function(id, all, container, settings){
alert('tabChanged');
return true;
}
});
这篇关于jQuery idTabs插件选项卡单击功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文