vendredi 17 mai 2019

Use of checkbox in linked button with that checkbox

The button is linked to the value check box. When I press the button, the value of the check box changes, but when I select the check box, it is automatically undone because it is in the same button. How can I solve this easy

if (document.getElementsByClassName("AUTO_SHUTDOWN_TOGGLE")[$(this).val() - 1].checked == false) {
  document.getElementsByClassName("AUTO_SHUTDOWN_TOGGLE")[$(this).val() - 1].checked = true;
} else {
  document.getElementsByClassName("AUTO_SHUTDOWN_TOGGLE")[$(this).val() - 1].checked = false;
}

<button class="AUTO_SHUTDOWN_BUTTON" value="5"><span>Auto Shutdown</span>
<input type="checkbox" class="AUTO_SHUTDOWN_TOGGLE"></button>




Aucun commentaire:

Enregistrer un commentaire