Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery for each all elements having similar id

Tags:

jquery

each

I have many elements accross page - ID1, ID2 ID3 ...

I want to manipulate all the elements. Is there any simpler way to do this.

$("#ID").each(function(){ ... });
like image 648
Ashwin Avatar asked Apr 24 '13 12:04

Ashwin


1 Answers

You can use ^ selector.

Example

$('div[id^="ID"]')

^= select DOM whose ID attribute starts with ID (i.e ID1, IDID,IDS,ID2 etc)

like image 69
Dipesh Parmar Avatar answered Oct 28 '22 04:10

Dipesh Parmar