lundi 5 mars 2018

Jquery check all selection by name or data

I have a list of checkbox like these:

   <li class="pods-pick"><div class="pods-field pods-boolean">
    <input name="pods_meta_type-a[0]" data-name-clean="pods-meta-type-a" data-label="type a" id="pods-form-ui-pods-meta-type-a0" class="pods-form-ui-field-type-pick" type="checkbox" tabindex="2" value="7505" wtx-context="BCB750E9-52A0-4F42-9733-31C9C7762617">
    <label class="pods-form-ui-label" for="pods-form-ui-pods-meta-type-a0">
        type-a1
    </label>
</div>
</li>
<li class="pods-pick"><div class="pods-field pods-boolean">
    <input name="pods_meta_type-a[0]" data-name-clean="pods-meta-type-a" data-label="type a" id="pods-form-ui-pods-meta-type-a1" class="pods-form-ui-field-type-pick" type="checkbox" tabindex="2" value="7506" wtx-context="BCB750E9-52A0-4F42-9733-31C9C7762617">
    <label class="pods-form-ui-label" for="pods-form-ui-pods-meta-type-a1">
        type-a2
    </label>
</div>
</li>

I can't use selection by class as I have another list on the same form with same class "pods-form-ui-field-type-pick".

How can I check all checkboxes with selection by name (but it's an array) or data-name-clean ?

I tried with

$('*[data-name-clean="pods-meta-type-a"]').prop('checked', true);

but doesn't work.

Thank you.




Aucun commentaire:

Enregistrer un commentaire