2016-05-21 2 views
0

私はanimate.cssで作業します。jQueryで別のスクリプトの後にスクリプトを実行

index.htmlを

<h1>Example</h1><div class="instagram-widget"></div>

index.js

jQuery('h1').mouseenter(function() { 
jQuery(this).addClass('fadeInUp').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ 
    jQuery(this).addClass('fadeOutUp').removeClass('fadeInUp').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ 
     jQuery(this).removeClass('fadeOutUp'); 
    }); 
}); }); 

すべての作品である:私はこのようなHTMLを持っています!


私はAPIを備えたInstagramを持っています(私の写真を表示できます - APIで心配する必要はありません)。 index.jsにAPIコードを追加します。私はここにすべてのコードを入れて質問を簡潔にしてはいけません。私はその後、私はjQuery('h1').mouseenter(function() {

jQuery('.comment').mouseenter(function() {にDoenst仕事を変更

jQuery('<a>').attr('href', url).append(// inside it, append an image jQuery('<img>').attr('src',src), jQuery('<div class="comment">').html(comment) ) // end append .appendTo('.instagram-widget')

を追加します。 1つのファイルでjQuery('.comment').mouseenter(function() {と同時に実行される.commentのように見えます。

QUESTION

どう.comment作品を作るには?別のスクリプトが完全に終了した後にスクリプトをロードする関数はありますか?

+0

競合を避けるために '.comment'を変更する方法はありますか? – claudios

+0

@claudiosもっと説明できますか? – ucon89

答えて

0

あなたはそれにはPromiseを使用できます - 良い方法、またはちょうど.setTimeout() - 悪い方法。

Promiseを使用すると、1つのコードが次々に実行されることが保証されます。

関連する問題