How do I get a element to appear/disappear once HTML document height is adjusted, in JQuery?
See code below

Objective: If the browser window has a vertical scroll, show #scroll-top...else hide #scroll-top. 

Problem: I have elements on my page that I can toggle therefore adjusting the page height, hence affecting if the browser scrollbar is visible or not.

Question: How do I get #scroll-top to disappear if I collapse/toggle all elements on the page & appear once I expand all elements?


    var hContent = $("body").height(); 
    var hWindow = $(window).height(); 

    if(hContent>hWindow) {
        $('#scroll-top').fadeIn(250);    
    }
    else {
        $('#scroll-top').fadeOut(250);
    }


Any help is Greatly Appreciated, Thanks
How do I get a element to appear/disappear once HTML document height is adjusted, in JQuery?
===

See code below

Objective: If the browser window has a vertical scroll, show #scroll-top...else hide #scroll-top. 

Problem: I have elements on my page that I can toggle therefore adjusting the page height, hence affecting if the browser scrollbar is visible or not.

Question: How do I get #scroll-top to disappear if I collapse/toggle all elements on the page & appear once I expand all elements?


    var hContent = $("body").height(); 
    var hWindow = $(window).height(); 

    if(hContent>hWindow) {
        $('#scroll-top').fadeIn(250);    
    }
    else {
        $('#scroll-top').fadeOut(250);
    }


Any help is Greatly Appreciated, Thanks