I have p tag and when I click on the p tag I want to toggle the checkbox's check. right now it only works on the first toggle. when I click on the p the box gets checked and when I click on it again the box gets unchecked but that's it. If I click on it again nothing happens on the screen. when I inspect element in firebug the checked attribute appears and disappears, which I think is what is supposed to happen, but nothing appears on the screen. I tried using prop() and it didn't work. here's what I have with attr()
$(".clickMe").on("click", function(){
if($("#thisBox").attr("checked") ){
$("#thisBox").removeAttr("checked")
}else{
$("#thisBox").attr("checked","checked")
}
})
And could someone tell me if there is a way to check to see if an element changes. Like **if**($(el).changes(){ do this } ) what's the pattern for that
Aucun commentaire:
Enregistrer un commentaire