【问题标题】:Accordion Jquery and page height in ajax callajax调用中的手风琴Jquery和页面高度
【发布时间】:2014-01-12 19:32:58
【问题描述】:

好的,所以我通过 ajax 调用页面并为其高度设置动画,效果非常好,接下来我有一个类似手风琴的功能来切换元素的可见性,然后另外调整包含元素的高度工作。 为什么?

function accordionfaq(){
    $('.question_all').on('click', function(event) {
        event.preventDefault();
        /* Act on the event */
        var newHeight = $('.faq').height();  //new height
        $(this).children('.answer').toggle('slow', function(){
            $('#loadplace').delay(200).animate({
                height:newHeight
            }).fadeIn();
        });
    });
}

带有完整代码和错误的jsfiddle: fiddle

【问题讨论】:

    标签: javascript jquery html css ajax


    【解决方案1】:

    好的,这里的问题是我在切换事件之前定义了高度......我有时很愚蠢......: 固定代码在这里:

    function accordionfaq(){
        $('.question_all').on('click', function(event) {
            event.preventDefault();
            /* Act on the event */
            $(this).children('.answer').toggle('slow', function(){
    
                var newHeight = $('.faq').height();  //THIS NEEDS TO go in here!!! not outside... 
    
                $('#loadplace').delay(200).animate({
                    height:newHeight
                }).fadeIn();
            });
        });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多