我试图获取数组中的所有可见项.它在Firefox中运行良好,但不适用于Chrome.
这是我的代码:
$.each (t.config.promoInput, function (i, v) {
var size = 0;
$.each ($(v).find('option'), function (i, v) {
$(v).show() // Show all options in <tt>$(v)</tt>.
.not(':first-child') // Don't hide <tt>(All)</tt>.
.not(':Contains("' + t.config.searchSpanInput.val() + '")') // Don't hide options that match the searchCriteria.
.hide(); // Hide everthing that doesn't match or isn't (All).
if ($(v).is(":visible")) {
size++;
}
});
});
Run Code Online (Sandbox Code Playgroud)
在Firefox大小增量中,而Chrome大小保持等于0.
编辑::包含是我自己添加到jQuery库.它是一个不区分大小写的版本:contains.
隐藏和显示(启用/禁用)选项不能很好地支持跨浏览器(禁用/启用)。请参阅此问题,了解问题的一种可能解决方案:jQuery disable SELECT options based on Radio selected (Need support for all browsers)
一旦你削减了选项,你就可以使用长度来获得尺寸。
归档时间: |
|
查看次数: |
3114 次 |
最近记录: |