0
目前,我设置了我的页面,当我点击一个div时,弹出的子菜单弹出出现在我点击的div下面。我试图分离()子菜单和insertAfter()和空白左或浮动,以便它出现在div被点击的右侧。HTML/jQuery detach()然后insertAfter()元素
* Here is a picture Example of what I currently have and what I am trying to do
HTML:
<div>
<div class="nav-name nav-padding">Alpha</div>
<div class="Beta">
<div class="Delta">
<div class="Omega">A</div>
<div class="Omega">B</div>
<div class="Omega">C</div>
<div class="Omega">D</div>
</div>
</div>
<div class="foo" style="display: none;"></div>
</div>
脚本:
function ClickItem() {
$('.nav-name').click(function() {
var itemText = $(this);
$(this).next('.delta').slideToggle('slow');
//$(this).next('.delta').toggle('slow');
//itemText.next().html().detach();
//itemText.next().html().insertAfter(.nav-name).css("margin-left", "20px");
});
}
我不知道这是否是最好的方法,如果我应该努力使这项工作。如果有更好的方法,请随时推荐一种不同的方法来完成我的任务。
谢谢
.html()返回一个字符串,字符串没有detach方法。我不认为你需要.html() –
你不能简单地使用** css **来定位子菜单..?!! –
另外,.next不会执行您认为的操作。 –