Home:ALL Converter>Two Javascript functions don't work together

Two Javascript functions don't work together

Ask Time:2018-01-14T18:26:42         Author:UbiRock Team

Json Formatter


I wanted to write some javascript functions for my theme and I'm a newbie in Javascript (So, Please don't laugh at me).
The first function is about navbar that when you scroll 400px, navbar will show from top. And second is about "goto-up" button.

window.onscroll = function() {scrollFunction()};

function scrollFunction() {
    if (document.body.scrollTop > 400 || document.documentElement.scrollTop > 400) {
        document.getElementById("goup").style.bottom = "0";
    } else {
        document.getElementById("goup").style.bottom = "-100px";
    }
};
window.onscroll = function() {goupFunction();};

function goupFunction() {
    if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 300) {
        document.getElementById("navbar").style.top = "0";
    } else {
        document.getElementById("navbar").style.top = "-50px";
    }
};

These two don't work together. I need your help. @Pedram, Fixed my problem. Thanks xD ( I added the second function to the first function and now those works together.)

Author:UbiRock Team,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/48248638/two-javascript-functions-dont-work-together
yy