我需要能够有一个显示div,并加载内容到该单个div,从其他div div without refreshing
页面。比方说,我有以下结构:动态显示div的内容在另一个div
Nav-div Display-div
-------------- -------------
| | | |
| >>item1<< | |content for |
| item2 | | item1 |
| item3 | | |
| | | |
| | | |
| | | |
-------------- --------------
的jQuery:
$("a.menu").click(function() {
var clicked = '#' + $(this).attr('title');
$('.toggle:not('+clicked+')').hide(1000);
$(clicked).show(1000);
});
HTML:
<div class="ShowClickedContent">
<!-- This Would be the display-div -->
</div>
<nav>
<a href="#" title="item1" class="menu">
<a href="#" title="item2" class="menu">
<a href="#" title="item3" class="menu">
</nav>
<div class="item1" style="display:none;">
<p> the content here will be loaded into the ShowClickedContent div </p>
</div>
<div class="item2" style="display:none;">
<p> the content here will be loaded into the div </p>
</div>
<div class="item3" style="display:none;">
<p> the content here will be loaded into the div </p>
</div>
截至目前,我只能得到的div自己在展现自己自己的容器,但不在showClickedContent
容器中。我将如何解决这个问题?
嘿, 谢谢。但是,第二种解决方案会导致我想要避免的确切问题。另外,我将如何在您提供的第一个示例中为开关设置动画?到目前为止,没有任何延迟(就像我在写我写的jQuery代码时那样)。 – Joel
嘿,再次,如果你能为我提供解决我上面的问题,我可以将其标记为答案。 – Joel