Im building an mobile app check if the username and password to be save and checked on checkbox , as I want to if checked then my "checkboxcs" class will show up the checked images else none. Here is my code:
function checkRPwd(){
var chbcv = $('#chb_re_pwd').attr('checked');
if(chbcv=="checked"){
$('#chb_re_pwd').attr("checked",false);
$('#chb_re_pwd')[0].checked=false;
$('.checkboxcs').removeClass("ckbcsselect");
}else{
$('#chb_re_pwd').attr("checked","checked");
$('#chb_re_pwd')[0].checked=true;
$('.checkboxcs').addClass("ckbcsselect");
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class="checkboxcs" href="javascript:checkRPwd();">
记住密码
<input id="chb_re_pwd" value="记住密码" type="checkbox" checked="checked">
</a>