marchemike
marchemike

Reputation: 3277

Scroll to span id after getting $_GET data

I'm trying to make the page scroll down on page ready, I can already detect the data from the $_GET variable. However, it does not scroll down to do the the selected element.

$(document).ready(function(){
var ok = "<?php echo (isset($_GET['gets'])) ? $_GET['gets'] : $_GET['gets'] ?>";
var a = "#number-"+ok;
$('body').scrollTop(a);
});

Upvotes: 0

Views: 161

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82241

Try this:

$('html, body').animate({
        scrollTop: $("#number-"+ok).offset().top
    }, 2000);

Upvotes: 2

Related Questions