2013-02-20 51 views
1

SlideToggle在我的网站无法正常工作。主要问题IT没有滑动,当我点击“显示”按钮时,它只是马上显示内容。但是,通过按下“隐藏”按钮,它完美地向上滑动以隐藏内容。这是我的JavaScript。谁知道这里可能是什么问题?slideToggle无法正常工作

$(document).ready(function(e) { 
$('.newsFull').hide(); 
$('.switch').click(function(e) { 
    $(this).parent().children('.switch').toggle(); 
    var text = $(this).parent().children('.newsFull'); 
    text.slideToggle(); 

}); 

});

这里是一个链接http://jsfiddle.net/ZxF9j/

+1

这似乎CSS/HTML相关的...就像如果jQuery的找不到元素的高度。请发布更多代码。小提琴将不胜感激。 – 2013-02-20 05:19:27

+1

这里是http://jsfiddle.net/ZxF9j/ – 2013-02-20 05:28:00

回答

4

只需添加

.newsFull {display:inline-block;} 

你的CSS

Check this fiddle

+1

完美的作品,谢谢! – 2013-02-20 05:37:19

+1

非常欢迎! – 2013-02-20 05:53:12

+1

这帮助了我很多,类似的情况!谢谢! – 2015-03-25 19:18:49