我正在努力编写适当的javascript来崩溃和扩展我的内容。
视图:
<div>
<h3 id="roleHeader" class="roleHeader collapsible">Title</h3>
<div>Content to display to users</div>
</div>javascript:
$(document).ready(function() {
//collapsible management
$('.collapsible').collapsible({
});
});发布于 2013-10-09 03:12:34
您可以很容易地实现一个
jQuery(function($){
$('.collapsible').click(function(){
$(this).next().stop(true, true).slideToggle();
}).next().hide()
})演示:小提琴
发布于 2013-10-09 03:04:19
你可能在找slideToggle。此函数将在上下滑动内容之间切换。
尝尝这个
$(document).ready(function() {
$('.collapsible').click(function(){
$(this).slideToggle(500);
});
});500是动画的速度。
你也可以瞄准你想要隐藏和显示的对象。要么给它一个Id、类,要么用jQuery专门针对它。在这里,当您单击具有collapsible类的任何内容时,下一个div将隐藏并显示。
$(document).ready(function() {
$(".collapsible").click(function(){
$(this).next("div").slideToggle(500);
});
});如果需要在再次单击动画以防止跳跃效果时停止动画,请在效果之前添加.stop(true)。
$(document).ready(function() {
$(".collapsible").click(function(){
$(this).next("div").stop(true).slideToggle(500);
});
});https://stackoverflow.com/questions/19262282
复制相似问题