
如果你要这么写,可以指定索引,
如:$("input[name=jizai]:eq(0)").attr("checked",'checked')这样就是第一个选中咯。
jquery中,radio的选中与否是这么设置的。
$("#rdo1").attr("checked","checked")
$("#rdo1").removeAttr("checked")
还有问题hi我哦。
首先添加给radio添加绑定单击事件,可以直接使用onclick="",也可以用jquery绑定;
$(function() {
showCont()
$("input[name=price_type]").click(function() {
showCont()
})
})
function showCont(){
var normal = document.getElementById("price_type1")
var special = document.getElementById("price_type2")
if (normal.checked) {
$("#sellInfo2").hide()
$("#sellInfo1").show()
}
if (special.checked) {
$("#sellInfo1").hide()
$("#sellInfo2").show()
}
}
结果:
使用:$( "#id" ).prop( "checked", true )$( elem ).attr( "checked" ) 1.6版本前返回值为boolean,
1.6+返回值为string,为属性的实际值,而不是boolean.
新的浏览器返回的是“checked”,老的浏览器返回的是true,所以不能使用attr
.prop()方法被用来处理boolean attributes
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)