dimanche 7 août 2016

Use checkbox to determine image class

I am trying to use the image associated with the checkbox to change class depending on if it is checked or not, but for some reason it will not change the class.

Code:

$('#providers_netflixNO').change(function() {
  if ($(this).is(":checked")) {
    $("#netflixNOLogo").removeClass("logoNotChecked").addClass("logoChecked");
    return;
  }
  $("#netflixNOLogo").removeClass("logoChecked").addClass("logoNotChecked");
});
<script src="http://ift.tt/1oMJErh"></script>
<label>
  <input type="checkbox" name="providers" id="providers_netflixNO" value="netflixNO">
  <img src="http://ift.tt/2aEZfZK" id="netflixNOLogo" class="logoNotChecked">
</label>



Aucun commentaire:

Enregistrer un commentaire