JQuery设置Radiobutton状态(是否选中)

贴代码:(HTML)

<td colspan=‘4‘ style="align:left">
    <input type="radio" style=‘width:10px‘ checked=‘checked‘ name="type" value="行政村" />行政村
    <input type="radio" style=‘width:10px‘ name="type" value="自然村" />自然村
</td>

JQuery代码:

$(‘input[name = "type"]:eq(0)‘).attr("checked", false);        //set first button checked, index begin: 0;
$(‘input[name = "type"]:eq(1)‘).attr("checked", true);        //set second button checked;
时间: 2024-07-30 11:05:52

JQuery设置Radiobutton状态(是否选中)的相关文章

jquery设置checkbox状态,设置dropdownlist选中值,隐藏某控件,给某控件追加东西

jquery设置checkbox状态 $("[ID$=chkType]").attr("checked", true); jquery设置dropdownlist选中值 $("[ID$=ddlSTATUS]").val("Not Submitted"); jquery隐藏某控件 $("[ID$=MEMO]").parent().parent().hide(); jquery给某控件追加Label $(&qu

jquery设置bootstrap-table的当前选中页码的获取与设置

一.获取当前table分页的页码 有两种方式可以获得当前选中的页码: 1.通过table的onPageChange方法 $('#agentTable').bootstrapTable({ data: {........}, onPageChange: function (pageNumber) { $.cookie("curAgentTablePageNumber", pageNumber); }, columns: [ {......} ]}); 2.通过table的getOptio

高版本jQuery设置checkbox状态注意事项

jQuery 1.9 以后, 使用 .attr(“checked”, true) 或  attr(“checked”, “checked”) 将无法正确设置 checkbox的状态, 同样的, 使用 .attr(“checked”) 也无法正确获取checkbox的状态 请从看到这篇文章开始, 使用 .prop(“checked”, true) 和 .prop(“checkbox”) 来设置和获取checkbox的勾选状态, 处于历史的考虑, 您可能更习惯使用 .is(“:checked”) 来

jquery 设置radio状态checked ,IE6、7 不兼容问题

设置radio为选中状态: $("#ownId").attr("checked",true); 但此方法在IE6.IE7下不起作用.在网上搜索了很多解决方案,无果. 现找到一个简易的方法解决该问题.原来IE6.IE7下控制选中状态的属性为“defaultChecked”. 修改代码如下: $("#ownId").attr("checked",true); document.getElementById("ownId&

jquery判断radioButton是否被选中

so easy HTML: <input type='radio' style='width:20px' id='other' name='projectType' value='其他' />其他(具体类别<input style='width:200px' type='text' name='exactKind' value='$!{form.exactKind}' />) JQuery: if($('#other').attr('checked')) { alert(); }

jquery设置、判断、获取input单选标签选中状态

1.设置某项单选input为选中状态: $("input[type='radio']").eq(1).attr('checked',true); ②也可设其属性checked为'checked',设置完后原选中项会自动取消选中 $("input[type='radio']").eq(1).attr('checked','checked'); 2.判断某单选框是否被选中状态: ? 使用object.attr('checked')==true是错的,应使用object.

JQuery设置checkbox选中或取消等相关操作

$("[name='checkbox']").attr("checked",'true');//全选 $("[name='checkbox']").removeAttr("checked");//取消全选 $("[name='checkbox']:even").attr("checked",'true');//选中所有奇数 //获取选择的值 var str=""; $

jquery版本间兼容性:checkbox选中状态

最近在学习Jquery,发现attr不太好用,从网上搜了下终于知道其原因,记下备查. 以下为以为网友在js贴吧的内容: 以<input type="checkbox" id="all"/>为例子取值的例子$("#all").attr("checked")在1.6前(含1.6),返回值是boolean类型的true或false:在1.6后,返回值是"checked"或undefined. 再来看赋

jquery设置select选中的文本

<select id="prov">  <option value="1">北京市</option>  <option value="2">上海市</option>  <option value="3">天津市</option> </select> 用jquery设置上面select选中的文本 //第一种方式 var count =