我有一个包含我的选项的选择标记:
<select name="series" onchange="changeCalc()" id="idCalcSelect" class="CalcSelect">
<option selected="1" style="display:none;">Series</option>
<option style="display:none;">Parallel</option>
<option style="display:none;">Semi</option>
</select>
我需要一个jquery代码,如果所有选项都有style =&#34; display:none;&#34;。
到目前为止,我需要一些东西
jq("#idCalcSelect").on("mouseover", function(){
jq("select[name='series'] > option[style]").each(function () {
/*jquery code here!*/
});
});
如果有一个选项标签与style =&#34; display:none;&#34;不匹配,则jquery代码必须返回false。
答案 0 :(得分:0)
我认为您可以将选项数量与hidden选项的数量进行比较。
jq("#idCalcSelect").on("mouseover", function(){
var options = jq(this).find('option');
// check if all options are hidden
if (options.length === options.filter(":hidden").length) {
// if so, do whatever
}
});