Pa3k.m
Pa3k.m

Reputation: 1166

How to scroll to top an overflow div with jquery?

$('.lb').click(function() {
    $('#modal').hide();

    var id  = $(this).attr('id');
    var dir = '/lightbox/' + id + '.php';

    $('#lightbox').find('#modal').load(dir, function() {
        $('#modal').show();
        $('#lightbox').fadeIn(200);
    });
});

I currently have a dynamic lightbox but everytime I scroll it to the bottom then load a different page, it stays scrolled into the bottom of #modal

I've tried

$('#modal').show();
$('#modal').scrollTop(0);
$('#lightbox').fadeIn(200);

but it doesnt work

any help would be great!

EDIT - forgot to mention that im using http://areaaperta.com/nicescroll/

Upvotes: 0

Views: 58

Answers (2)

Suganth G
Suganth G

Reputation: 5156

$('#div').scrollTop(0); 

works fine

LIVE_DEMO

Upvotes: 1

Waqar Alamgir
Waqar Alamgir

Reputation: 9978

This should work:

$('#lightbox').find('#modal').load(dir, function() {
    $('#modal').show();
    $('#modal').scrollTop(0);
    // Do also
    $('#modal').scrollLeft(0);
    $('#lightbox').fadeIn(200);
});

Upvotes: 0

Related Questions