在JavaScript中找到其他关系

时间:2016-03-15 03:18:09

标签: javascript jquery html

我有一个很大的功能,它有许多其他的功能,(但我不能拥有所有这些功能,因为我的其他脚本出错了)因此我只需要做出我需要的动作的功能;最近我帮助找到了一个功能,但我认为哪个隐藏其他功能隐藏内容,并显示我需要的按钮。当我运行脚本运行良好,但没有显示一个按钮,当你返回到初始位置时也没有隐藏该栏。我测试了大脚本只是为了知道是否有我的错误和元素是的。

你可以在这里找到的大脚本以及我正在尝试做的例子See the code and example

您可以看看我正在尝试对此图片和问题做些什么: See Picture of the problem

我当前的脚本是这样的,效果很好,但是错过了大脚本中的那两个细节。请帮帮我。

db.demo.aggregate([ 
{$group:{_id:"$name",
    a:{$sum:"$a"},
    b:{$sum:"$b"}}},
{$project:{name:1,a:1,b:1,_id:1,bdiva:{$cond:[{$eq:["$a",0]},0,{$divide:["$b","$a"]}]}}},
{$sort:{bdiva:1}}
])

1 个答案:

答案 0 :(得分:0)

如果你想显示按钮(箭头),你需要在你的HTML中添加它然后你可以使用这个脚本:

<!-- language: lang-js -->

// JavaScript Document

;
jQuery(document).ready(function() {
    "use strict";
    jQuery(window).scroll(function() {
        var scrollTop = jQuery(window).scrollTop();
        var docHeight = jQuery(document).height();
        var winHeight = jQuery(window).height();
        var scrollPercent = (scrollTop) / (docHeight - winHeight);
        var scrollPercentRounded = Math.round(scrollPercent * 100);
        jQuery('#post_indicator').css('width', scrollPercentRounded + '%');
    });



     jQuery(window).scroll(function() {
        var calScreenWidth = jQuery(window).width();
        if (jQuery(this).scrollTop() > 200) {
            jQuery('#toTop').stop().css({
                opacity: 0.5,
                "visibility": "visible"
            }).animate({
                "visibility": "visible"
            }, {
                duration: 1000,
                easing: "easeOutExpo"
            });
        } else if (jQuery(this).scrollTop() == 0) {
            jQuery('#toTop').stop().css({
                opacity: 0,
                "visibility": "hidden"
            }).animate({
                "visibility": "hidden"
            }, {
                duration: 1500,
                easing: "easeOutExpo"
            });
        }
    });
    jQuery('#toTop, .hr_totop').on('click', function() {
        jQuery('body,html').animate({
            scrollTop: 0
        }, 800);
    });


    jQuery(window).scroll(function() {
        if (jQuery('#pp_fixed_menu').val() == 1)

        {
            if (jQuery(this).scrollTop() >= 200) {
                jQuery('.header_style_wrapper .above_top_bar').hide();
                jQuery('.extend_top_contact_info').hide();
                jQuery('.top_bar').addClass('scroll');
                jQuery('#post_info_bar').addClass('scroll');
            } else if (jQuery(this).scrollTop() < 200) {
                jQuery('.header_style_wrapper .above_top_bar').show();
                jQuery('.extend_top_contact_info').show();
                jQuery('#custom_logo img').removeClass('zoom');
                jQuery('#custom_logo img').css('maxHeight', '');
                jQuery('#custom_logo').css('marginTop', parseInt(logoMargin) + 'px');
                jQuery('#menu_wrapper div .nav > li > a').css('paddingTop', menuPaddingTop + 'px');
                jQuery('#menu_wrapper div .nav > li > a').css('paddingBottom', menuPaddingBottom + 'px');;
                jQuery('.top_bar').removeClass('scroll');
                jQuery('#post_info_bar').removeClass('scroll');
            }
        } else {
            if (jQuery(this).scrollTop() >= 200) {
                jQuery('.header_style_wrapper').addClass('nofixed');
            } else {
                jQuery('.header_style_wrapper').removeClass('nofixed');
            }
        }
    });

});

当你向上滚动时,栏不会再次隐藏?我在这里测试这个小脚本,当我向上滚动时它隐藏它