jeudi 13 août 2015

How to fetch the value of checkbox of the triggered button only in jquery?

<tr>
    <td>Category 1</td>
    <td class="data">
        <ul>
            <li>
                <input name="items[]" type="checkbox" value="1"> Item 1
                <input name="items[]" type="checkbox" value="2"> Item 2
            </li>
        </ul>
    </td>
    <td>
        <button class="save">Save</button>
    </td>
</tr>

<tr>
    <td>Category 2</td>
    <td class="data">
        <ul>
            <li>
                <input name="items[]" type="checkbox" value="1"> Item 1
                <input name="items[]" type="checkbox" value="2"> Item 2
            </li>
        </ul>
    </td>
    <td>
        <button class="save">Save</button>
    </td>
</tr>

The table is dynamically created with jquery. So, what I want is when I click one of the save button, I want to fetch the checked data from the checkbox of that only consisting that clicked button, not from the other checkboxes.




Aucun commentaire:

Enregistrer un commentaire