checkbox默认是选中状态,submit背景颜色默认是橘色,checkbox未选中时submit变灰色。 一开始用的纯css实现的,但是5s上系统版本是8.3不兼容,checkbox未选中时submit确认按钮不变色
/*.mycheck input + label + input{background: #CDCDCD;}*///是这句话不起效果,现在我还是不知道什么原因
/*.mycheck input:checked + label + input{
background-color: #FB793B;
}*/
并且JS判断不管是浏览器还是手机都判断不出来
if($("input[type='checkbox']").is(':checked')=='false'){
$("input[type='submit']").css("background","#CDCDCD");//这句判断不出来,但是true可以判断出来
}
最终代码:
<div class="mycheck">
<input class="checkbox " type="checkbox" value="1" id="checkbox1" name="" checked="checked"/>
<label for="checkbox1"></label>
获得你的公开信息(昵称 头像等)
<input class="cur" type="submit" value="确认"/>
</div>
JS代码:
$(function () {
$('.checkbox').on('click',function(){
if($(this).attr('checked')){
$("input[type='submit']").removeClass('cur');
$(this).removeAttr('checked');
}
else{
$("input[type='submit']").addClass('cur');
$(this).attr('checked','checked')
}
});
});
.mycheck label{
background-image:url(img/wopay-.png);display: inline-block;height: 36px;width: 36px;
background-repeat: no-repeat;margin-bottom: -8px;margin-right: 10px;
}
.mycheck input:checked + label{
background-image:url(img/wopay-OK.png);background-repeat: no-repeat;
}
input[type="submit"]{display:block;width: 690px;height: 86px;border: none;border-radius: 8px;text-align: center;
font-size: 34px;line-height: 34px;-webkit-appearance: none;margin-top: 30px;-webkit-tap-highlight-color: transparent;
background-color: #CDCDCD;color: #fff;
}
.mycheck .cur{
background-color: #FB793B;
}