0

I have a series of li items that I want to select based on the class name and if it contains the string 'award'

I have the following html..

<li class="award"></li>
<li></li>
<li class="award-open"></li>

How do I select the two li items that have the class with the string 'award' in it?

Zabs
  • 13,852
  • 45
  • 173
  • 297

3 Answers3

9

You need http://api.jquery.com/attribute-contains-selector/

$("[class*='award']")
Adil Shaikh
  • 44,509
  • 17
  • 89
  • 111
1

Use:

$('.elementClass[class^="xyz"]').each(function() {
// do something
});
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
1
   if(getElementByTagName("li")[i].className=="award";)

This will do from java script otherwise in jquery already answered by @Adil and in place of i you have to loop it in for because tag name will return more than one li select as much you want.