tags:

views:

24

answers:

1

I'm trying to build a search box for a select list, and I'm looking for some suggestions on doing this with jQuery. My goal is to hightlight <option/>'s that contain the search string or hide all <option/>'s that don't. I thought I was on to something with attribute selectors until I realized that I'm searching on the HTML content and not an attribute.

<select name="Users" id="Users">
  <option value="123">Frank Smith ([email protected])</option>
  <option value="456">Joe Banks ([email protected])</option>
</select>
+1  A: 

Have a look at the contains() selector http://api.jquery.com/contains-selector/

$("option:contains('Joe')");
sunn0