mercredi 18 janvier 2017

set checked depending on data-selection value

I have a data-selection.

<div id="accordion" data-selection="<?php echo $_SESSION['sessionNumber']; ?>">

in my accordion i have a input field

    <div id="accordion">
    <label class="">
                     <h2>title</h2>
                    <input type='checkbox''/>
                </label>

<label class="">
                     <h2>title</h2>
                    <input type='checkbox''/>
                </label>
    </div>

so now I have two data-selection 0 and 1 I the checkbox to be checked on the value of the data-selection.

for example if data-selection ="0" the the first will be checked if 1 then the second, this needs to be dynamic.

anyone know how to do this ?

I have done something like this with the active accordion

  $(function () {
    var $accordion = $("#accordion");
    $accordion.accordion({
        autoHeight: true,
        collapsible: true,
        active: $accordion.data("selection")
    });
    )

the active state is dynamical set depending on the data-selection value.

I would like the same function for the check.

Aucun commentaire:

Enregistrer un commentaire