I have a jQuery reference to a HTML select list. I need to iterate the options and check to see if the text of the option matches a regex, if it does I want to add a cssclass to the option. How do I do this?
var ddl = $($get('<%= someddl.ClientID %>'));
Can I take advantage of the .each() function somehow?
Example
<select id="someddl">
<option value="21">[21] SomeData ***DATA***</option>
<option value="22">[22] SomeData ***DATA***</option>
<option value="23">[23] SomeData </option>
<option value="24">[24] SomeData </option>
<option value="25">[25] SomeData ***DATA***</option>
</select>
I want to add a CSS class to items 1, 2, 5 in this sample.
In c# my regex was Regex expression = new Regex(@"\*\*\*");
but I want to do this through javascript now, so it's likely the regex will look a bit different.
Any ideas what I can do here to accomplish the requirement?
Thanks, ~ck