JQuery Select all tables with an identifier starting with

I would like to select all tables where id begins with the same sentence, with jquery.

This is 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 tables starting with "Tab _" and not tables with id = "xyz"

I would like to use this code to create a similar navigation with this plugin: http://projects.allmarkedup.com/jquery_evtpaginate/demo_basic.html

Can anyone help me out?

Many thanks.

Alessandro

+5
source share
3 answers

Try the following:

$('table[id^=Tab_]')
+11
source

Padolsey . .

$("table:regex(id, ^Tab)")

.

+2

filter():

$('table').filter(function(index){
    return this.id.substring(0,4) == 'Tab_';
});
+1

All Articles