javascript jQuery 选择所有以 id 开头的表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3513569/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery Select all tables with id starting by
提问by rossale
I would like to select all the tables where the id starts with the same sentence, with jquery.
我想用jquery选择id以相同句子开头的所有表。
This what I mean:
这就是我的意思:
<table id="Tab_01">
<tr>
<td>....
<tr>
....
</table>
<table id="Tab_02">
<tr>
<td>....
<tr>
....
</table>
<table id="Tab_03">
<tr>
<td>....
<tr>
....
</table>
<table id="xyz">
<tr>
<td>....
<tr>
....
</table>
What I need, is to select the tables that start with "Tab_"and not the table with id = "xyz"
我需要的是选择以“Tab_”开头的表,而不是 id =“xyz”的表
I would like to use this code for making a similar navigation with this plugin : http://projects.allmarkedup.com/jquery_evtpaginate/demo_basic.html
我想使用此代码与此插件进行类似的导航:http: //projects.allmarkedup.com/jquery_evtpaginate/demo_basic.html
Could anyone help me ???
有人可以帮我吗???
Thanks a lot.
非常感谢。
Alessandro
亚历山德罗
回答by Ken Redler
Try this:
试试这个:
$('table[id^=Tab_]')
回答by Teja Kantamneni
回答by Aaron Digulla
Use a filter():
使用filter():
$('table').filter(function(index){
return this.id.substring(0,4) == 'Tab_';
});

