按钮没有出现在Javascript中?

时间:2014-07-25 09:58:54

标签: javascript jquery html

我有这段代码:

var go_top = $('.go-top');
function btn_go_top() {
    if (go_top.length) {
        var scroll_top = $(window).scrollTop(),
                go_top_height = go_top.outerWidth(),
                footer = $('.footer'),
                nav = $('.nav'),
                nav_top = nav.offset().top,
                nav_height = nav.height(),
                f_height = footer.height(),
                w_height = $(window).height(),
                f_top = footer.offset().top,
                go_top_margin = go_top_height + 40,
                popravka = (w_height - go_top_margin)/2;
        if (scroll_top > (nav_top + nav_height)) {
            go_top.css('margin-bottom', -go_top_height/2);
            go_top.fadeIn();
        }
        else{
            go_top.fadeOut();
        };
        if ((scroll_top + go_top_margin + popravka) > f_top) {
            go_top.css({'position': 'absolute', 'bottom': f_height + go_top_margin/2});
        }
        else {
            go_top.css({'position': 'fixed', 'bottom': '50%'});
        };
    };
}

带按钮的Html标签是。 使用按钮标记,但滚动错误时按钮不可见: 未捕获的TypeError:无法读取属性' top'未定义的 (匿名功能) jQuery.event.dispatch elemData.handle 哪里实现了错误以及如何修复它?谢谢你的回答。

0 个答案:

没有答案