I have a group of id's with similar names (ex: div1, div2, div3) that are all going to perform the same function. is there an easy way in jQuery to create an array by calling the prefix of the id ("div")?
+1
A:
You can use this attribute selector to test the start of the ID attribute value:
[id^=div]
Gumbo
2009-10-19 17:03:52
awesome, thanks!
homer
2009-10-19 17:10:23
+1
A:
You can create a filter selector that gets all divs where the id starts with "div" like this:
$("div[id^='div']")
Vincent Ramdhanie
2009-10-19 17:05:12
A:
I suggest the id values of your divs are div1, div2, div3.
$("div[id^=div]")
This doesn't work anymore:
$('div#div\\S*')
powtac
2009-10-19 17:06:06