home

Jquery Go To Top

Where to use

Hi it very useful thing for content based website like new portal or tutorials portal, if a page has more content, user is now in the bottom of the page if he wants to go top of the page by the time it will help. Even it is user-friendly also so use it make attractive just follow the step understand and use it.

Jquery Code

Here some jquery example code with id and events with functions, we have button (#gotop) with click event, when user clicks on Go To Top button total document scroll (with animation)top ("0px").

Just observe the code, code will demonstrate.
$("#gotop").click(function(){
$("html, body").animate({
scrollTop: "0px" }, 800);
});

HTML code

HTML code with to div elements one is for content (forcontent) and remine is for button (Go To Top).

<div id="forcontent">Enter text here about your business</div>
<div id="gotop">Top</div>

Css code

#gotop{
width:200px;
background:#00a4fa;
border:1px solid #000;
padding:3px;
}
#forcontent{
height:700px;
width:400px;
background:#ff0000;
}