the code:
<form>
<div class="term"><input type="checkbox" />I agree to the terms of the privacy </div>
<div id="tip"> please agree the terms of the privacy </div>
</form>
the jquery code:
$(document).ready(function() {
$("#tip").hide();
jQuery("form").submit(function() {
if (jQuery('.term').is(':checked')) {
jQuery("#tip").hide();
}
else {
jQuery("#tip").show();
return false;
}
});
});
when i checked the checkbox, then submit the form, the tips still shows. why?
Your selector for “term” is a div, not a checkbox. The checkbox is a child of “term”