Hus*_*ein 3 performance jquery jquery-selectors
是否有更高效的方式来写这个.
$('#test').find('option:selected[value!=""]')
Run Code Online (Sandbox Code Playgroud)
您可以稍微调整它,但使用方法而不是Sizzle:
$('#test').find('option').filter(function() {
return this.selected && this.value.length
});
Run Code Online (Sandbox Code Playgroud)
基准:http://jsperf.com/sizzle-vs-methods-filter/12
.filter() 对我来说快了约70%.
| 归档时间: |
|
| 查看次数: |
256 次 |
| 最近记录: |