I'm adding a hide event to this script so the button doesn't show in mobile and it won't work. Can anybody tell me why it is so, please?
<SCRIPT>
var $ = jQuery.noConflict();
jQuery(document).ready(function( $ ){
scrollToTop.init( );
});
var scrollToTop =
{
init: function( ){
//Check to see if the window is top if not then display button
$(window).scroll(function(){
if ($(this).scrollTop() > 100) {
$('.scrollToTop').fadeIn();
} else {
$('.scrollToTop').fadeOut();
}
});
// Click event to scroll to top
$('.scrollToTop').click(function(){
$('html, body').animate({scrollTop : 0},800);
return false;
});
// Check to see if window is mobile, if yes then hide button
$(window).on('resize', function()
{
if($(this).width() > 600)
{
$('.scrollToTop').hide();
}
});
// Check to see if window is mobile, if yes then hide button
}
};
</SCRIPT>
And these are the styles:
<STYLE>
.scrollToTop{
width: 100px;
height: 130px;
padding: 10px;
text-align:center;
background: whiteSmoke;
font-weight: bold;
color: #444;
text-decoration: none;
position:fixed;
bottom: 75px;
right: 40px;
background: url('../_images/icons/arrow_up.png') no-repeat 0 20px;
}
</STYLE>
And this is the what the html looks like:
<HTML>
<BODY>
<NAV>
<a href='#top_of_page' class='scrollToTop' style='display: inline;'>Scroll To Top</a>
</NAV>
</BODY>
</HTML>