我正在尝试打开有条件的选项卡2。选项卡2应打开,如果选中的复选框比选项卡1中的复选框多,否则选项卡2将不会打开。我该怎么做呢?
脚本:http://jsfiddle.net/mktgnp3e/694/
$("#tabs").tabs({
beforeActivate: function(e, ui) {
var id = $(ui.newPanel).attr('id');
if(id=="tabs-2")
if($('input[name="chk"]:checked').length > 1){
alert("Tab 2 opened");
}else{
alert("Please select checkbox more then one in tab 1 otherwise tab 2 will not open");
} } }
);
发布于 2018-09-05 17:46:22
为了保持第一个选项卡处于活动状态,您可以在第一个条件中执行$(this).tabs({ active: 0 });
,here's更新后的示例。
发布于 2018-09-05 18:13:21
试试这个:$("#tabs").tabs({ activate: function (e, ui) { var id = $(ui.newPanel).attr('id'); if (id == "tabs-2") { if ($('input[name="chk"]:checked').length < 2) { alert("Please select checkbox more then one in tab 1 otherwise tab 2 will not open"); $("#tabs").tabs("option", "active", 0); } else { alert("Tab 2 opened"); } } } });
https://stackoverflow.com/questions/52181811
复制相似问题