2017-04-25 116 views
1

我第一次使用Jquery & JqueryUI。我有一個名爲frontdiv,我想在窗口加載時顯示,並在延遲5500後通過滑動隱藏。 但是它在jquery.min.js中給出錯誤。顯示和隱藏不工作在Jquery

的HTML代碼是'

<head> 
    <style> 
    #front { 
     width: 400px; 
     height: 400px; 
     display: none; 
    } 
    </style> 
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"> 
    </script> 
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> 
    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"> 
</head> 



<body> 
    <div id="front"> </div> 

<script> 
    function slider() { 
    $("#front").show("fade",500); 
    $("#front").delay(5500).hide("slide",{direction:"right"},500); 
    } 
    window.onload = function() { 
    slider(); 
    } 
</script> 
</body> 
</html> 

的jsfiddle https://jsfiddle.net/t29rh9sL/1/
和我收到錯誤消息

Uncaught TypeError: r.easing[this.easing] is not a function
at init.run (jquery.min.js:3) at i (jquery.min.js:3) at Function.r.fx.tick (jquery.min.js:3) at eb (jquery.min.js:3)

+1

有什麼錯誤?你有沒有在頁面中包含jqueryui.js?這是一個單獨的文件jquery.js –

+0

「div命名爲前」與div與ID =「前」「? –

+0

@RoryMcCrossan是的,你說的對,我在HTML頁面中添加了CDN鏈接。錯誤是在jquery.min.js,我不知道,但在檢查它顯示---- >>>「」'jquery.min.js:3 Uncaught TypeError:r.easing [this.easing]是而不是函數 at init.run(jquery.min.js:3) at i(jquery.min.js:3) at Function.r.fx.tick(jquery.min.js:3) at eb (jquery.min.js:3)'「」 –

回答

0

沒有ID名稱#mainContainer在你的鱈魚即

你應該放置在ID身體像 <body id="mainContainer"><div id="front"> </div></body>

+0

我很抱歉,但那只是輸入錯誤。問題解決了。包含資源文件的順序錯誤。不過謝謝。 –