javascript - Scroll to top button won't work when implement to PHP -
i no means web developer forgive me if missing blindly obvious. trying add scroll top button this awesome guy static html site , work when splitting 2 parts put <head>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"> <div class='thetop'></div>
and rest <footer>
<div class='scrolltop'> <div class='scroll icon'><i class="fa fa-4x fa-angle-up"></i></div> </div> <script> $(window).scroll(function() { if ($(this).scrolltop() > 50 ) { $('.scrolltop:hidden').stop(true, true).fadein(); } else { $('.scrolltop').stop(true, true).fadeout(); } }); $(function(){$(".scroll").click(function(){$("html,body").animate({scrolltop:$(".thetop").offset().top},"1000");return false})}) </script>
so when trying implement php, still split 2 parts. 1 header.php , 1 footer.php, static site both local , live site not display anything. added button css css file.
my header.php
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title><?php bloginfo('title'); ?></title> <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"> <div class='thetop'></div> <?php wp_head(); ?> </head>
my footer.php
<div class='scrolltop'> <div class='scroll icon'><i class="fa fa-4x fa-angle-up"></i></div> </div> <script> $(window).scroll(function() { if ($(this).scrolltop() > 50 ) { $('.scrolltop:hidden').stop(true, true).fadein(); } else { $('.scrolltop').stop(true, true).fadeout(); } }); $(function(){$(".scroll").click(function(){$("html,body").animate({scrolltop:$(".thetop").offset().top},"1000");return false})}) </script> <?php wp_footer(); ?> </div> </body> </html>
then thinking adding both of them index.php , remove them header.php , footer.php still not working.
any pointers appreciated.
put <div class='thetop'></div>
after <head>
inside body
wiki
Comments
Post a Comment