簡體   English   中英

最近/下一個div選擇jquery

[英]closest/next div selecting jquery

我有這樣的HTML:

<table>
 <tr>
  <td>
    <button class="popup" id="$row[0]"></button>
  </td>
 </tr>
</table>



 <div class="details">
   <div id="section-2">
   </div>
 </div>

這里是JQuery腳本:

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

我想用類詳細信息對最近/下一個div進行對話

details元素是table元素的下一個兄弟,所以使用.closest()查找button的表祖先然后使用.next()來查找details元素

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM