禁用select下拉方法

采用的原理是将select下的未被选中的option 移除掉javascript

 

 

 <form id="sss" action="/Home/Edit" method="post"> 
     <select name="Area" style="" readonly="readonly" dic-select-disable="true">
         <option>请选择</option>
         <option value="jiangxi" selected="selected">江西</option>
         <option value="zhejiangs">浙江</option>
     </select>

     <button type="submit">提交</button>
 </form>
</div>

 

 1 <script type="text/javascript">
 2     $(function () {
 3         $("select[dic-select-disable='true']").each(function (i, dom) {
 4             if ($(dom).attr("dic-select-disable") == "true")
 5             {
 6               $(dom).find("option").not("option:selected").remove();
 7             }
 8         });
 9     });
10 </script>
Js Code

 

更多demo详见:个人博客网java

相关文章
相关标签/搜索