How To Show "back To Top" Button Using Jquery Only If Browser Height Is Shorter Than Page?
How to add/show 'back to top' button at bottom in a div using jquery only if height browser height is shorter than page, other wise it should be hidden?
Solution 2:
$(document).ready(function(){
showHideControl();
$(window).resize(function(){
showHideControl();
});
});
functionshowHideControl() {
var h = $(window).height();
var ch = $("#content").height();
if (ch < h) {
$("#backControl").hide();
}
else {
$("#backControl").show();
}
}
The html needs to be updated a little too:
<divid="mainwrapper"><divid="content"><p> Paragraph 1 </p><p> Paragraph 1 </p><p> Paragraph 1 </p><p> Paragraph 1 </p></div><pid="backControl"><ahref="#mainwrapper">Back to top</a></p></div>
Post a Comment for "How To Show "back To Top" Button Using Jquery Only If Browser Height Is Shorter Than Page?"