Count Upwards for ID jQuery?

You could use a substring selector to get most of the way there: var divs = $('divid^=test-'); // All divs with IDs starting with "test which would work better if you changed the naming convention a bit so the number was at the end. But I think I'd lean toward using some other aspect of the structure (the parent node), or a class, or a data-xyz attribute Edit A pair of substring selectors can do it: var divs = $('divid^=test-'). Filter("divid$=yay") That gets all of the ones whose IDs start with "test-" and then filters out the ones that don't end with "yay Close anyway.

You could use a substring selector to get most of the way there: var divs = $('divid^=test-'); // All divs with IDs starting with "test-" ...which would work better if you changed the naming convention a bit so the number was at the end. But I think I'd lean toward using some other aspect of the structure (the parent node), or a class, or a data-xyz attribute... Edit A pair of substring selectors can do it: var divs = $('divid^=test-'). Filter("divid$=yay"); That gets all of the ones whose IDs start with "test-" and then filters out the ones that don't end with "yay".

Close, anyway...

Thx :) and to everyone else as well – Tom May 18 '10 at 12:20.

– Tom May 18 '10 at 12:04 This is a valid alternative but does not answer the actual question. – user113716 May 18 '10 at 12:13.

You could try something like: $("divid^='test'") or $("divid$='yay'") or try to combine the two Manual.

You could do it like that: $("divid^=test-"). Each(function(){ //selects all dives having the string 'test-' in it $that = $(this) $that. Text($that.

Attr("id"). Split("-")1) //splits the sting by "-" and gives you out the middle part (in your case the number) }) test it here jsfiddle.net/aj5Qk/1.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions