mercredi 25 mai 2016

Cannot uncheck the checkbox with jquery prop()

I have a simple cod, and I don't know why it is not working. When I click on the button, I want to uncheck the checkbox. I was trying with prop(), I was trying with attr(), and still nothing.

Maybe someone here can see the mistake?

HTML

<label>
  <input type="checkbox">
</label>

<button>CLICK</button>

jQuery

var btn = $("button");

    btn.on("click", function(){
    var checked = $(label).find("input").prop("checked");
        if (checked === true){
            $("checked").prop("checked", false);
        }
  })

http://ift.tt/1XweK7J




Aucun commentaire:

Enregistrer un commentaire