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 (fsmith@example.com)</option>
  <option value="456">Joe Banks (jbanks@example.com)</option>
</select>
1

1 Answer 1

1

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.