我的Javascript似乎不起作用(部分)

时间:2018-07-11 17:38:54

标签: javascript jquery

我正在尝试使用延迟和显示为欢迎文本提供一些动画。当我在本地测试时,一切正常。但是,当我尝试在实时服务器上运行它时,“首次延迟加载”和“首页的jquery”中的代码根本不起作用,而“响应式操纵器”部分中的代码却可以正常工作??? 如果整个脚本不起作用,那么我可能会发现一些问题,但奇怪的是其中一些正在起作用。

谁能告诉我发生了什么事?

这是HTML

<div ng-controller="homeController" class="ng-scope">
<div class="flex-box welcome">
    <h1 id="line1" class="hvr-pulse">Welcome to my basement</h1>
    <h3 id="line2" class="hvr-pulse">I hope these will satisfy you</h3>
    <button id="welcome-button" class="hvr-grow-rotate" ng-click="about()">Allow me to introduce myself</button>
</div>
    听到我的问候->

这是Javascripts文件,网站网址为https://namwin.herokuapp.com/

$(document).ready(function() {
    // first load on delay
    $('#line1').hide().delay(3000).show(2200);
    $('#line2').hide().delay(5000).show(2200);
    $('#welcome-button').hide().delay(10000).show(2200);

    //responsive manipulator
    $('.fa-bars').on('click',function () {
        var x = document.getElementById("nav-bar");
        if (x.className === 'nav-bar')
            x.className += ' responsive';
        else
            x.className = 'nav-bar';
    })

    // jquery for front page
    $('#greet').click(function() {
        var audio = document.getElementById('audio');
        if (audio.paused) {
            audio.play();
        }else{
            audio.pause();
            audio.currentTime = 0
        }
    })
});

1 个答案:

答案 0 :(得分:0)

由于您使用的是角度代码,因此请将此代码放置在模块中。 您正在调用代码,而元素尚未出现。