1.首先需要引入select插件的js和css(样式可以自己修改)
2.循环出下拉列表,我的项目使用AngularJS所以用ng-repeat
3.调用select插件的搜索方法
<link rel="stylesheet" href="asset/css/combo.select.css"/> <select class="form-control input-sm" ng-model="goods.supplierId" name="supplierId" id="supplierId"> <option value="" selected="selected">请选择供应商</option> <option ng-repeat="party in partyList" ng-selected="goods.supplierId == party.partyid" value="{{party.partyid}}">{{party.partyname}} </option> </select> <script src="library/jquery.combo.select.js"></script> <script> $(function () { setTimeout(function (){ $("#supplierId").comboSelect(); },500) }); </script>
4.说明 调用模糊搜索的方法必须在select数据加载完之后,否则会没有数据