Note that there are some explanatory texts on larger screens.

plurals
  1. POif-else statement for the document position top not working
    text
    copied!<p>I'm struggling to get an if else statement to work.</p> <p>I'm trying to get the page to recognise when it was at the top and to hide the footer if the user was to scroll manually to the top. I've looked into a few approaches but can not get this to work. Is my code completely wrong with the if else format? or is the <code>("$html").offset().top</code> not the right approach to gathering if the window is scrolled to the top.</p> <p>I apologise if this has already been asked but I couldn't find it in my searches.</p> <p>Here's my code:</p> <pre><code>$(".releases").click(function(){ if ($("html").offset().top) { $("#content").load('content.php #releases'); //load the content into the main ajax div $("#banner").stop().animate({ 'background-position-x' : '-700px', 'background-position-y' : '-500px'}, //background position change 2000, function() {$.scrollTo("#content", 3000); //returns to the main page content $("#footer").animate({"bottom": "0px"}, 3000); // animate the footer back into view }); } else{ $("#footer").animate({"bottom" : "-150px"}, 3000); //animate footer out of view $('html, body').stop().animate({ scrollTop: 0 }, 3000, function(){ //bring window to the top $("#content").load('content.php #releases'); //load the content into the main ajax div $("#banner").stop().animate({ 'background-position-x' : '-700px', 'background-position-y' : '-500px'}, //background position change 2000, function() {$.scrollTo("#content", 3000); //returns to the main page content $("#footer").animate({"bottom": "0px"}, 3000); // animate the footer back into view }); }); }); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload