开发者

Search a select list with jquery

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 a开发者_如何学Cnd 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>


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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜