lundi 19 janvier 2015

append text when checkbox is checked

I'm having an issue while trying to append text to a label when the checkbox is checked. When I submit the form the text is sent to an e-mailadress that is entered by the user with Mandrill.


The problem that I'm facing is that I always get the false value even if I have checked the checkbox. I have already looked at the "Check checkbox checked property" but none of the solutions work in my case. I have the following html & jQuery:


HTML:



<form id="vcardForm" method="post">
<input id="chkbox1" type="checkbox" />
<label id="lbl1"></label>
<input type="submit" id="submitbtn"/>


jQuery:



<script>
if($('#chkbox1').is(':checked')) {
$('#lbl1').append("\n Checked is true!");
}else {
$('#lbl1').append("\n Checked is false!");
}

</script>


Any help would be greatly appreciated


Thanks.





Aucun commentaire:

Enregistrer un commentaire