我不得不使用下面的CSS来建立一个自定义复选框:jQuery来检查CSS自定义复选框已被选中
input[type="checkbox"] {
display:none;
}
input[type="checkbox"] + label span {
display:inline-block;
width:19px;
height:19px;
margin:-1px 4px 0 0;
vertical-align:middle;
background:url("../image/checkbox.png") 0 -20px no-repeat;
cursor:pointer;
}
input[type="checkbox"]:checked + label span {
background:url("../image/checkbox.png") 0 -1px no-repeat;
}
但是,如果复选框被选中或不与下面的,现在我有在检查问题功能:
var radio_check = $('#one input[type="checkbox"]');
function add_color(element, color){
element.css('background-color', color);
}
function checkEmailFormat(){
if(emailReg.test(emailaddressVal)) {
add_color(email, red);
}
else {
return true;
}
}
function check_Radio_Checkb(){
if(!radio_check.is(':checked')){
alert('no');
}
else{
alert('yes');
// return true;
}
}
function validate_form(){
$('form input:not(.email input), textarea').each(function(){
if ($(this).val() == '') {
add_color($(this), red);
}
else {
add_color($(this), white);
}
});
return (checkEmailFormat() && true);
}
<div class="checkbox_wrapper">
<input type="checkbox" id="one" />
<label for="one">
<span></span>
I agree with the terms and conditions and privacy policy
</label>
<input type="checkbox" id="two" />
<label for="two">
<span></span>
Join the Krušovice VIPs for the latest news, competitions and promotions.
</label>
</div>
'var radio_check = radio_check'? – undefined 2013-05-09 11:06:08
抱歉拼写错误var radio_check = $('#one input [type =“checkbox”]'); – Alex 2013-05-09 11:06:40
你可以发布你的标记吗? – billyonecan 2013-05-09 11:07:43