在一个页面中,我有几个选项卡,我问是否可以通过切换单击来启用禁用选项卡功能。
选项卡代码如下所示:
jQuery('.tabs a').click(function() {
var ref = jQuery(this).attr('href').split('#')[1];
jQuery('div.tab_content:not(#' + ref + ')').hide();
jQuery('#' + ref).fadeIn();
return false;
});对于切换,我使用:http://papermashup.com/demos/ajax-switch/
抱歉,如果我不能张贴一个链接。它是一个简单的iPhone风格的切换开关。
非常感谢
发布于 2011-04-19 19:05:52
根据我的理解,你是指这样的东西吗?
//global variable you can change it anywhere
var disable_function = false;
jQuery('.tabs a').click(function() {
if (!disable_function ){
var ref = jQuery(this).attr('href').split('#')[1];
jQuery('div.tab_content:not(#' + ref + ')').hide();
jQuery('#' + ref).fadeIn();
return false;
}
});编辑:
var disable_function = false;
jQuery('.tabs a').click(function() {
if (!disable_function ){
disable_function = true;
var ref = jQuery(this).attr('href').split('#')[1];
jQuery('div.tab_content:not(#' + ref + ')').hide();
jQuery('#' + ref).fadeIn();
return false;
}
});上面的代码将只执行此函数一次
https://stackoverflow.com/questions/5715176
复制相似问题