jeudi 29 août 2019

Shortest way to count the checked attributes

I have a list of checkbox in AEM When we hit the checkbox the checked attribute will be placed on the parent element, not in the input box. I want the count how many are checked

$('.isCorrectanswer').attr('checked').length;
<coral-checkbox class="isCorrectanswer" checked>
    <input type="checkbox" name="./checkboxone" />
    <label>checkbox</label>
  </coral-checkbox>
  <coral-checkbox class="isCorrectanswer" checked>
    <input type="checkbox" name="./checkboxtwo" />
    <label>checkbox</label>
  </coral-checkbox>
  <coral-checkbox class="isCorrectanswer">
    <input type="checkbox" name="./checkboxthree" />
    <label>checkbox</label>
  </coral-checkbox>
  <coral-checkbox class="isCorrectanswer">
    <input type="checkbox" name="./checkboxfour" />
    <label>checkbox</label>
  </coral-checkbox>
  <coral-checkbox class="isCorrectanswer">
    <input type="checkbox" name="./checkboxfive" />
    <label>checkbox</label>
  </coral-checkbox>

This is not working for me...




Aucun commentaire:

Enregistrer un commentaire