Q:

How to convert a MooTools 'Scroll to Top' Script to jQuery

Hello friends I have the following script in my Template:
window.addEvent('domready', function () {
    var a = $('totop');
    if (a) {
        var b = new Fx.Scroll(window);
        a.setStyle('outline', 'none').addEvent('click', function (e) {
            new Event(e).stop();
            b.toTop()
        })
    }
});

I wanted this in jQuery as I don't want to load 2 libraries just for this bit of script. I am actually very new to programming and still in the learning stage. Hence looking forward for some help on this issue.
Kindly Help.

A:

$(function() {
    var $a = $('#totop');

    if ($a.length != 0) {
        $a
            .css('outline', 'none')
            .click(function(e) {
                $(window).animate({scrollTop: 0}, 1000);
                return false;
            });
    }
});

