mercredi 25 mars 2015

check if checkbox :check is not working, why, jquery?

What did I do wrong? see code below and run it. I am trying to check if the box if check or not with jquery. It doesn't work. Why? If I refresh the page and keep the checkbox check, then it will echo alert.





if($("#faith").is(':checked')){
alert('hello');
}
if($("#diet").is(':checked')){
alert('hello');
}



<input type="checkbox" name="cureway" id="faith" value="faith" /><label for="faith">My faith</label>
<input type="checkbox" name="cureway" id="diet" value="diet" /><label for="diet">My diet</label>
<input type="checkbox" name="cureway" id="exer" value="exer" /><label for="exer">My excercise</label>






Aucun commentaire:

Enregistrer un commentaire