我有一个多选下拉菜单并且在选择一个特定的选项卡时我需要打开引导选项卡,我只能显示选项卡,但只有在我单击选项卡后才会显示选项卡的内容,任何人都可以告诉我我正在做的错误吗?
这是我的下拉代码
<select name="subrole" id="subrole" class="inversed dropdown multiCheckbx triggerTab" multiple="multiple" ng-model="subrole"
multiselect-dropdown required>
<option value="Actor" class="actor" id="actor" href="Actor"> Actor </option>
<option value="Director" class="director" id="director" href="Director"> Director </option>
<option value="Lyricist" class="lyricist" id="lyricist" href="Lyricist"> Lyricist </option>
<option value="Music Director" class="musicdirector" id="musicdirector" href="MusicDir"> Music Director </option>
<option value="Singer" class="singer" id="singer" href="singer"> Singer </option>
<option value="Standup Comedian" class="standupcomedian" id="standupcomedian" href="standupcomedian"> Standup Comedian </option>
</select>
这是我的剧本
$('.triggerTab').on('change', function(e) {
//var subbtn = document.getElementsByClassName("last")[0];
//$(subbtn).show();
$('#tabscontainer').show();
var selected = new Array();
selected = $('.triggerTab').val();
//alert(selected[0]);
if(jQuery.inArray("Singer", selected) !== -1) {
$($("#myTab").find("li")[0]).show();
}
else {
$($("#myTab").find("li")[0]).hide();
}
DisplayTab();
要显示我的标签容器,请使用以下函数调用DisplayTab(),但默认显示特定标签,而不显示所选标签
function DisplayTab() {
var selecteditems = new Array();
selecteditems = $('#subrole').val();
if(selecteditems!==null && selecteditems.length!== 0)
{
//$('#tab-2').show();
// $('#myTabs a[href="#menu2"]').tab('show') // Select tab by name
$('#tabscontainer').show();
}
else {
//$('#myTabs a[href="#menu2"]').tab('hide') // Select tab by name
$('#tabscontainer').hide();
}
}
如何显示特定标签内容?
答案 0 :(得分:0)
这段代码会检查所选选项的数量,然后显示标签。
if ($("#subrole option:selected").length > 0) {
// You might need a trigger for the tab
$('#tabscontainer').trigger('click');
// or follow your logic if that works
$('#tabscontainer').show();
}