只是想改善我的选择器.我有很多行,但我需要排除具有"table_row valuetemplate"类的行.
<table>
<tr class="table_row"></tr>
<tr class="table_row"></tr>
<tr class="table_row"></tr>
<tr class="table_row valuetemplate"></tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我知道的很快:
$(".table_row")
Run Code Online (Sandbox Code Playgroud)
这个慢得多:
$(".table_row:not(.valuetemplate")
Run Code Online (Sandbox Code Playgroud)
这是排除的唯一方法吗?
$(".table_row:not(.valuetemplate)") 似乎最快(在Chrome 13和FF 5中测试,来自Chrome的结果)
http://jsperf.com/not-jquery-selectors
$(".table_row").not('.valuetemplate')
$(".table_row:not(.valuetemplate)")
$("table").children(":not(.valuetemplate)");
| 归档时间: |
|
| 查看次数: |
115 次 |
| 最近记录: |