简体   繁体   English

获取$ _GET数据后滚动到span id

[英]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. 我正在尝试让页面在页面上向下滚动,我已经可以检测到$ _GET变量中的数据了。 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);
});

Try this: 尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM