span动态切换

来源:互联网 发布:unity3d 烘焙场景 编辑:程序博客网 时间:2024/05/22 11:53

html部分:

<span class="z_yes" style="float:left;" ><label id="labY" for="z_yes" checked="checked">是</label></span>

<span class="z_fou" style="float:left;"><label id="labN" for="z_no">否</label></span>
<input type="radio" name="active" value="1" id="z_yes" checked="checked" style="display: none"/>
<input  type="radio" name="active" id="z_no" value="0"  style="display: none"/>



js部分:


if(active==0){
$(".z_yes").attr('style',"float: left; background: rgb(233, 233, 233); color: rgb(151, 151, 151);");
$(".z_fou").attr('style',"float: left; background: rgb(27, 188, 155); color: rgb(255, 255, 255);");
$("#labN").attr('checked',true);
$("#z_fou").attr('checked',true);

}else{
$(".z_fou").attr('style',"float: left; background: rgb(233, 233, 233); color: rgb(151, 151, 151);");
$(".z_yes").attr('style',"float: left; background: rgb(27, 188, 155); color: rgb(255, 255, 255);");
$("#labY").attr('checked',true);
$("#z_yes").attr('checked',true);


}

效果:

0 0
原创粉丝点击