select控件是一个特别的控件,没有readOnly属性,所以要设置只读属性有点麻烦了。
方法如下:
$(document).ready(function(){
$("#countries").focus(function(){
$(this).attr('defaultIndex',$(this).attr('selectedIndex'));
});
$("#countries").change(function(){
$(this).attr('selectedIndex',$(this).attr('defaultIndex'));
});
});
<select id="countries">
<option value="1">Country1</option>
<option value="2">Country2</option>
<option value="3">Country3</option>
<option value="4">Country4</option>
<option value="5">Country5</option>
<option value="6">Country6</option>
<option value="7" selected="selected">Country7</option>
<option value="8">Country8</option>
<option value="9">Country9</option>
</select>
后期还得优化,虽然不可再选择,但是框显示出来让人觉得还可再选择。
分享到:
相关推荐
昨天网上找了很多关于设置select checkbox radio只读的,都没办法满足要求,自己写了一个
目前发现的最好用的select控件,支持多选,搜索,多选关闭删除,文档全面,使用方便,界面美观。
Jquery双向select控件Bootstrap Dual Listbox,可动态获取数据!
简单实用的jquery select2组件
jquery-ui jquery控件 jquery时间控件 js时间控件
jquery.selectbox.js select下拉菜单美化代码 jquery.selectbox.js select下拉菜单美化代码 jquery.selectbox.js select下拉菜单美化代码
NULL 博文链接:https://zhengjie-dna.iteye.com/blog/1007813
Jquery模拟select效果实现,纯自写,简单实用,可自行修改样式。
1.jquery.inputer为替代select控件开发! 2.本控件经过测试,兼容IE,火狐! 3.本控件可以自由扩展! 4.本控件为原创,代码有些凌乱,但功能齐全! ---本控件代码为本人编写,完全处于分享拿出来的,有什么地方写的...
jquery漂亮日期控件 jquery美化
jquery 时间控件 时间格式是2012-5-12 17:52:52这样的有用的可以下载不是当前时间为2012-5-22 00:00:00这样的 下载看自己要什么的。在做修改 ,在cal.js最后
jquery控件jquery控件jquery控件jquery控件jquery控件jquery控件
jquery时间控件时分秒,相当不错,很推荐
下拉模糊查询 jQuery-select 下拉模糊查询 jQuery-select 下拉模糊查询 jQuery-select 下拉模糊查询 jQuery-select 下拉模糊查询 jQuery-select 下拉模糊查询 jQuery-select
jquery 动态添加控件
jquery 时间控件实例jquery 时间控件实例jquery 时间控件实例jquery 时间控件实例jquery 时间控件实例
jquery手机日期控件_html5手机网页手机日期选择器代码 jquery手机日期控件_html5手机网页手机日期选择器代码 jquery手机日期控件_html5手机网页手机日期选择器代码
简洁漂亮的jquery日期选择控件代码
jquery 日期时间控件, 必要依赖及示例, 避免重复劳动
Jquery时间日期控件[日期时间-日期-时间]日期时分秒,单独日期,单独时分秒,附demo,颜色可自行修改