
首先添加给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()
}
}
结果:
你的$("input[name=jizai]")这个选择器会获得两个radio对象,都设置选中,只能最后一个是被选中的,因为是单选。如果你要这么写,可以指定索引,
如:$("input[name=jizai]:eq(0)").attr("checked",'checked')这样就是第一个选中咯。
jquery中,radio的选中与否是这么设置的。
$("#rdo1").attr("checked","checked")
$("#rdo1").removeAttr("checked")
还有问题hi我哦。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)