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

设置radio为选中状态:

$("#ownId").attr("checked",true);

但此方法在IE6、IE7下不起作用。在网上搜索了很多解决方案,无果。

现找到一个简易的方法解决该问题。原来IE6、IE7下控制选中状态的属性为“defaultChecked”。

修改代码如下:

$("#ownId").attr("checked",true);
document.getElementById("ownId").defaultChecked = true;
时间: 2024-07-31 10:25:42

jquery 设置radio状态checked ,IE6、7 不兼容问题的相关文章

jquery设定radio的checked无效

环境:chrome + jquery.2.1.1.min.js 设置一次为checked的状态后,再一次设置radio状态,无效. 如: $('input[type="radio"][name="name"]').attr("checked", "checked"); $('input[type="radio"][name="name"]').attr("checked&quo

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 设置checkbox的checked属性 总是出问题

所使用的jquery版本为jquery-1.9.1,浏览器为Chrome 1.通过prop方法获取checked属性,获取的checked返回值为boolean,选中为true,否则为flase <input type="checkbox" id="selectAll" onclick="checkAll()">全选 function checkAll() {   var checkedOfAll=$("#selectAll

jquery 设置 radio

<label id="worksRedio"> <span style="margin-left: 34px;"><input type="radio" name="works_file_type" value="0" >视频</span> <span style="margin-left: 34px;"><input t

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

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

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&q

jquery设置radio选中

<script type="text/javascript"> $(document).ready(function(){ $("input[type=radio][name=sex][value=1]").attr("checked",true); }); </script> 您的性别: <input type="radio" name="sex" value="1

jquery 根据值设置radio选中状态

radio选中 $("input[name=test][value=34]").attr("checked",true);//value=34的radio被选中 $("input[id=testid][value=34]").attr("checked",true);//value=34的radio被选中 jquery 根据值设置radio选中状态

点击tr实现选择checkbox功能,点击checkobx的时候阻止冒泡事件, jquery给checkbox添加checked属性或去掉checked属性不能使checkobx改变状态

给tr添加点击事件,使用find方法查找tr下的所有层级的元素,children只查找下一层级的元素,所以使用find.find的返回值为jquery对象,在这个项目中不知道为什么使用jquery给checkbox添加checked属性或去掉checked属性不能使checkobx改变状态,所以我就把jquery对象转换为DOM对象,怎么转呢?jquery对象[0]或者get(0)就转换成DOM对象,然后直接.checked返回true或false就可以判断checkbox是否选中了.然后判断状