开发中,会遇到在谷歌中input type=radio点选没有反应,在火狐中input type=radio样式不能修改的问题,这里有个小窍门:
<label class="lab"><input name="addup_flag" type="radio" value=“1” />是</label>
<label class="lab"><input name="addup_flag" type="radio" value=“0” />否</label>
把input的透明度设置为0,按钮选没选中的效果用background:url(...) no-repeat;来写。
CSS:
.lab input{filter:alpha(opacity=0);-moz-opacity:0;-khtml-opacity: 0;opacity: 0;}
.lab{display:inline-block;background:url(../images/home_default.png) no-repeat;margin-right:3px;cursor:pointer;}
.onCheck{background:url(../images/home_radio.png) no-repeat;}
JS:
$("body").on("click",".lab",function(){
$(this).attr("class","lab onCheck");
$(this).siblings().attr("class","lab");
})
效果: