| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
cn55
11年前发布

jQuery 设置多选框 单选框 下拉框选中和取消选中(selected)

//设置单选下拉框选中  $("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  });