jQuery wildcard selection

Posted by Yuval A on Stack Overflow See other posts from Stack Overflow or by Yuval A
Published on 2010-05-06T09:02:13Z Indexed on 2010/05/06 9:08 UTC
Read the original article Hit count: 215

Filed under:
|

Suppose you have some <div>s:

<div id="div_num1"></div>
<div id="div_num2"></div>
<div id="div_num3"></div>

You can select all those divs by choosing $("div[id^='div_num']"). How can you buld a function that references the number succeeding the prefix?

For example, a function which will alert the number 3 for "div_num3".

More generally, how can you use full-blown regex in jQuery selectors?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about regex