<div style="float:left;margin-right:5px;">
<input value="" id="selectInput" onkeyup="searchItem(this,'selectMem');" style="150px;height:24px;line-height:24px;border:1px solid #929292;font-size:14px;border-radius:2px;" type="text">
<select size="5" value="" id="selectMem" style="display: block; 154px;margin-top: 5px;border:1px solid #929292;">
<option value="14cda0c4-0837-4311-a071-3987cf268cc1">小李子</option>
<option value="641f116a-e0ae-48bc-ad2b-d96686250eb7">小王子</option>
<option value="41ad48a9-9c49-4525-9f9b-9dd6bad9b734">花花</option>
<option value="c06061fd-6b79-486c-b6af-56c2f941c69f">乐乐</option>
<option value="d0a6f33b-4ff5-400c-b5d3-2e81d7528764">高山</option>
<option value="5ba44538-ed19-4644-844b-8acec1e11bde">云海</option>
<option value="be35d654-6de8-4603-8d94-57d9d99ae561">云印</option>
<option value="fc8d5cbe-b979-4564-8357-eeafff801a0d">水滴</option>
</select>
</div>
在input上设置onkeyup事件,输入文字时触发
function searchItem(e,myselectid){ var keywords = $(e).val(); keywords=keywords.replace(/ /g,"") //去掉空格 var myselect=$("#"+myselectid)[0]; //得到select对象 if(keywords!=""){ for(i=0;i<myselect.length;i++)// 循环option { if(myselect.options[i].text.indexOf(keywords)!=-1) //判断option的text是否包含keyword { $option = $(myselect.options[i]); $(myselect.options[i]).remove(); $(myselect).prepend($option); } } } //alert(myselect.options.length); }