Simple Machines Community Forum

Customizing SMF => Graphics and Templates => Topic started by: TwitchisMental on September 13, 2012, 07:56:36 PM

Title: Jquery go to top not wanting to work.
Post by: TwitchisMental on September 13, 2012, 07:56:36 PM
So I am trying to make a simple go to top button slowly slides to the top when click.(Hence why I am using jquery lol)


I have tried a few different ways to do this and for some reason no matter what the animation never happens. It just instantly goes to the top.


Here is the code itself -





<script type="text/javascript">
   $.noConflict();
   $(document).ready(function(){
$(function() {
$(window).scroll(function() {
if($(this).scrollTop() != 0) {
$("#top").fadeIn();
} else {
$("#top").fadeOut();
}
});

$("#top").click(function() {
$("body,html").animate({scrollTop:0},800);
});
});</script>


I have a few other jquery scripts aswell,but they all work fine.
Title: Re: Jquery go to top not wanting to work.
Post by: mashby on September 13, 2012, 08:44:03 PM
jQuery is awesome, ain't it? Wondering if you could provide a page where this is on? And did you get this code from another site? Only reason I ask is that it would give a baseline of where it's working.
Title: Re: Jquery go to top not wanting to work.
Post by: The Craw on September 14, 2012, 12:31:50 AM
I'm rather curious about the source as well. I played with this a good bit earlier and couldn't get it to scroll smoothly up. It's weird too, because I've used that particular type of code on several auto scrolling applications. But like you said, it just jumps right up with no real scrolling action.
Title: Re: Jquery go to top not wanting to work.
Post by: TwitchisMental on September 14, 2012, 10:12:56 PM
It seems a I made a double topic lol.. Can everyone just go to this topic -


http://www.simplemachines.org/community/index.php?topic=486343.0 (http://www.simplemachines.org/community/index.php?topic=486343.0)


I have replied to it with the latest update.