closest/next div selecting jquery

javascript, jquery

Solution

The `details` element is the next sibling of the `table` element, so use .closest() to find the table ancestor of the `button` then use .next() to find the `details` element

$(document).ready(function () {
    $('.popup').click(function () {
        // something like this : $(this).next(".details").dialog('open');
        $(this).closest('table').next('.details').dialog('open');
    });
});

Problem

I have HTML like this: ``` <table> <tr> <td> <button class="popup" id="$row[0]"></button> </td> </tr> </table> <div class="details"> <div id="section-2"> </div> </div> ``` Here goes JQuery script: ``` $(document).ready(function() { $('.popup').click(function () { // something like this : $(this).next(".details").dialog('open'); $('.details').dialog('open'); }); }); }); ``` I want to dialog closest/next div with class details

Original source