<p><!-- JS --><script type="text/javascript">
$(document).ready(function($) {
$('#accordion').find('.accordion-toggle').click(function(){
//Expand or collapse this panel
$(this).next().slideToggle('fast');
//Hide the other panels
$(".accordion-content").not($(this).next()).slideUp('fast');
});
});
</script><!-- CSS -->
<style type="text/css">.accordion-toggle {cursor: pointer;}
.accordion-content {display: none;}
.accordion-content.default {display: block;}
</style>
<!-- HTML --></p>
在点击之前,我可以在哪里放置代码以使默认加载全部关闭?
答案 0 :(得分:0)
要默认关闭手风琴,请将下面的行放在document.ready
$(document).ready(function($) {
$(".accordion-content").slideUp('fast');
$('#accordion').find('.accordion-toggle').click(function(){
//Expand or collapse this panel
$(this).next().slideToggle('fast');
//Hide the other panels
$(".accordion-content").not($(this).next()).slideUp('fast');
});
});
答案 1 :(得分:0)
你可以看到click和unlick之间的html区别是什么。单击后,html将改变样式,从&#34;显示:黑色;&#34;进入&#34;显示:无;&#34;。所以你应该知道如何编码!