dimanche 1 mars 2015

checkbox.attr("checked) as if sentence clause

I have a checkbox that I want to use as a control for my jQuery program, but can't seem to get the if sentence right (I want something to happen if the box is checked). I've set up a fiddle below to illustrate what's going on.





function checkPick() {
if ($('#prePick').attr('checked')) {
console.log("I want to see the previous picks!");
}
};

checkPick();



<div class="options">
<input type='checkbox' name='prePick'> Show Logged Picks
</div>






Aucun commentaire:

Enregistrer un commentaire