[英]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.