Home | Blog | Screencasts | Projects
# Saturday, November 29, 2008

I came across an interesting scenario the other day where I needed to select some html elements with JQuery that had a class name like:

   1: <input type="radio" class="star star_id_45 star_group_5" />

I wanted to be able to select the elements that contained the class ‘star_id_45’, which as you can see is in the middle of the class string.

 

The answer was the following code:

 

   1: $("input[class*='star_id_45']")

 

Notice the use of the asterix (*), that was the key to getting the selector to work properly.

Saturday, November 29, 2008 1:56:00 AM (E. Australia Standard Time, UTC+10:00)  #    Comments [0] - Trackback
JQuery
Statistics
Total Posts: 191
This Year: 0
This Month: 0
This Week: 0
Comments: 41