2016-09-23 85 views
0

我有一個網站,我正在努力。當我到達某個div時,我想讓div滾動顯示(淡入淡出),然後消失(淡入淡出)。無法在滾動上實現淡入淡出?

<div id="div1"> 
    <p class="welcomePar3">Welcome to my website! Here you will find all information related to me. Feel free to browse around!</p> 
    <div id="UWIMAGE"> 
     <img id="imageActual" src="img/uw.jpg"> 
    </div> 
</div> 
$('#div2').fadeInScroll(); 
$('#div2').fadeInScroll({ 
    minDistance: 75 * $(window).height()/100 
}); 

沒有運氣。我該怎麼辦?

+2

[文件](https://github.com/maugelves/FadeInScroll)只是說:「**當你的文件已經準備好**,應用fadeInScroll()函數的DOM元素時。屏幕到達元素的頂部,它會淡入。「你確定你的代碼是在文檔準備好的時候執行的嗎? – kosmos

+0

它似乎不起作用@ kosmos?如何檢查文件是否準備好? – Aakarsh

回答

0

你知道如果文檔已經準備好使用jQuery,這是一個衆所周知的事件。 在這裏,你有你的代碼應該是什麼樣子的例子:你的IDS

// to wrap code around the jQuery document ready event 
$(document).ready(function(){ /* stuff */ }); 

// or (shorthand for above) 
$(function(){ /* stuff */ }); 

// so your code could look like this 
$(function(){ 
    $('#div2').fadeInScroll(); 
}); 

保重,在你的js代碼使用#div2,但你的HTML有div1爲ID。

如果您進入插件頁面(https://github.com/maugelves/FadeInScroll),您可以看到一個名爲index.html的文件。你有一個它是如何的例子。

https://learn.jquery.com/using-jquery-core/document-ready/