<div id="demo">
<div class="moduletable">
<div class="demo">
<div class="demo-wrap">
<div class="container" id="button-1">Button-1 contents</div>
<div class="ctrl">
<div><a href="#buttton-1">Button-1</a>
</div>
</div>
</div>
</div>
</div>
</div>
jQuery
$('ctrl').click(function(){
$(this).closest('.container #button-1').width();
// 如何先选择类容器,然后选择它的 id 是button-1}
编辑
<div class="container" id="button-1">Button-1 contents</div>
<div class="container" id="button-2">Button-2 contents</div>
<div class="ctrl">
<div><a href="#buttton-1">Button-1</a>
</div>
</div>
如果按下一个按钮,我如何获取容器宽度作为它的 id,它应该提醒 button-1 宽度,如果另一个它应该提醒 button-2。