我需要能夠有一個顯示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