有没有更高效的方式来写这个。
$('#test').find('option:selected[value!=""]')
您可以稍微调整它,但使用方法而不是 Sizzle:
$('#test').find('option').filter(function() {
return this.selected && this.value.length
});
基准: http://jsperf.com/sizzle-vs-methods-filter/12 http://jsperf.com/sizzle-vs-methods-filter/12
.filter()
对我来说快了 70% 左右。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)