如何获取最接近使用jquery点击的按钮的ul的id?第二组中的按钮似乎正在返回我最顶级的ul。感谢。
div class="First">
<ul id="One">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
<button type="button" id="4444" onclick="GetClosestUl()">Get Closest Ul to button</button>
</div>
<div class="First">
<ul id="Two">
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
<button type="button" id="5555" onclick="GetClosestUl()">Get Closest Ul to button</button>
</div>
<script type="text/javascript">
function GetClosestUl() {
console.log($("button").closest() + " this is ul id");
}
</script>