0
我只想在啓動時打開一個抽屜。目前,所有抽屜都是開放的。啓動時無法通過jQuery顯示一個抽屜
在體內jQuery code
$(document).ready(function() {
// hide all ULs inside LI.drawer except the first one
$('LI.drawer UL:not(:first)').hide();
// apply the open class
$('li.drawer:first ul').addClass('open');
$('h2.drawer-handle').click(function() {
// hide the currently visible drawer contents
$('li.drawer ul:visible').hide();
// remove the open class from the currently open drawer
$('h2.open').removeClass('open');
// show the associated drawer content to 'this' (this is the current H2 element)
// since the drawer content is the next element after the clicked H2, we find
// it and show it using this:
$(this).next().show();
// set a class indicating on the H2 that the drawer is open
$(this).addClass('open');
});
});
的HTML
<ul class="drawers">
<li class="drawer">
<h2 class="drawer-handle open">Contact</h2>
<ul>
<li>A</li>
<li>B</li>
</ul>
</li>
<li class="drawer">
<h2 class="drawer-handle">papers</h2>
<ul>
<li>A</li>
<li>B</li>
</ul>
</li>
</ul>
你怎麼能顯示出一個抽屜和隱藏在啓動時休息嗎?
謝謝指出! – 2009-04-14 23:14:23