Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我的Javascript没有';t似乎在工作(部分)_Javascript_Jquery - Fatal编程技术网

我的Javascript没有';t似乎在工作(部分)

我的Javascript没有';t似乎在工作(部分),javascript,jquery,Javascript,Jquery,我试图给我的欢迎文本一些动画使用延迟和显示。当我在本地测试时,一切正常。然而,当我尝试在live server上运行它时,“首次加载延迟”和“jquery for front page”中的代码根本不起作用,而“responsive manipulator”部分中的代码起作用??? 如果整个脚本都不起作用,那么我可能会想出一些办法,但奇怪的是,其中有些办法起作用了 有人能告诉我发生了什么事吗 这是HTML <div ng-controller="homeController" class=

我试图给我的欢迎文本一些动画使用延迟和显示。当我在本地测试时,一切正常。然而,当我尝试在live server上运行它时,“首次加载延迟”和“jquery for front page”中的代码根本不起作用,而“responsive manipulator”部分中的代码起作用??? 如果整个脚本都不起作用,那么我可能会想出一些办法,但奇怪的是,其中有些办法起作用了

有人能告诉我发生了什么事吗

这是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>

由于您正在使用angular,请将此代码放在模块中。
您正在调用代码,而元素还不在那里。

您还可以包含与问题相关的HTML吗?这些元素可能不在DOM中。您可以添加一些HTML的完整图片吗?
delay()
!=
setTimeout()
这两种方法完全不同,正如API明确指出的那样,延迟不是setTimeout的替代品我不太明白您想要实现什么,但作为旁注,jQuery提供了方法
hasClass()
addClass()
removeClass()
,因此,您的
if
语句应该类似于
if(x.hasClass('responsive')){x.removeClass('responsive')}或者{x.addClass('responsive')}
。还请注意,它具有可选参数
duration
complete
回调,您可以使用它们来链接方法。不管怎样,你的动画在Safari上对我有用。我刚刚添加了HTML。我的错,是delay()而不是setTimeout。对于Alejandro的问题,我试图给我的元素#line1,#line2,#欢迎文本一些延迟,然后在用户首次加载页面时显示它。现在他们没有延迟(即使在本地延迟功能工作…)顺便说一句,我正在使用Chrome,也许这就是原因?
$(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
        }
    })
});