jQuery 设置多选框 单选框 下拉框选中和取消选中(selected)
2018-07-20 来源:open-open
//设置单选下拉框选中
$("input:eq(0)").click(function () {
$("#single option").removeAttr("selected"); //移除属性selected
$("#single option:eq(1)").attr("selected", true); //设置属性selected
});
//设置多选下拉框选中
$("input:eq(1)").click(function () {
$("#multiple option").removeAttr("selected"); //移除属性selected
$("#multiple option:eq(2)").attr("selected", true); //设置属性selected
$("#multiple option:eq(3)").attr("selected", true); //设置属性selected
});
//设置单选框和多选框选中
$("input:eq(2)").click(function () {
$(":checkbox").removeAttr("checked"); //移除属性checked
$(":radio").removeAttr("checked"); //移除属性checked
$("[value=check2]:checkbox").attr("checked", true); //设置属性checked
$("[value=check3]:checkbox").attr("checked", true); //设置属性checked
$("[value=radio2]:radio").attr("checked", true); //设置属性checked
});
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
最新资讯
热门推荐