Javascript 在滚动div上加载

Javascript 在滚动div上加载,javascript,scroll,Javascript,Scroll,我试图在没有任何动画的情况下在特定点加载content div HTML <div class="fixed-block"> Fixed Block </div> <div class="content"> Content </div> JS .fixed-block { background: red; height: 400px; width: 100%; position: fixed;

我试图在没有任何动画的情况下在特定点加载content div

HTML

<div class="fixed-block">
    Fixed Block
</div>

<div class="content">
    Content
</div>
JS

.fixed-block {
    background: red;
    height: 400px;
    width: 100%;
    position: fixed;
    top: 0;
}

.content {
    height: 700px;
    margin-top: 400px;
    background: yellow;   
    position: relative;
}
if(window.location.hash) {
    var hash = window.location.hash;
    var link = $("[href='"+ hash +"']");
    if ( hash == "" ) {
        $('html, body').animate({
            scrollTop: $(".content").offset().top
        }, 1000);
}
它是这样工作的:

var hash = window.location.hash;
var link = $("[href='"+ hash +"']");
if ( hash == "" ) {
    $('html, body').animate({
        scrollTop: $(".content").offset().top
    }, 1000);
}

我删除了这个:
if(window.location.hash){
,原因如下:

1-如果缺少
块,则该
块的结束括号

2-检查空字符串是否具有布尔值没有意义

3-您已经在此处检查:
if(hash==“”)