Jquery go to top not wanting to work.

Started by TwitchisMental, September 13, 2012, 07:56:36 PM

Previous topic - Next topic

TwitchisMental

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.

mashby

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.
Always be a little kinder than necessary.
- James M. Barrie

The Craw

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.

TwitchisMental

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


I have replied to it with the latest update.

Advertisement: