2012-08-25 49 views
0

我有工作得很好,一些jQuery效果(slideUp()等)。使用jQuery效果()'埃德

現在我​​後setTimeout div在那裏和效果不再起作用。

這是因爲div的未在​​我相信之前就已存在。

的影響和​​都在同一個JS文件,並且都包裹在jQuery(document).ready(function($) { /*They are here*/ });

我如何可以調用這些div這些影響後,在​​「版?

+0

你可能需要用'.live()'動態的東西http://api.jquery.com/live/ –

+2

@tq - '.live( )'已被棄用,不應再被推薦。 '.on()'或'.delegate()'是替代品。在沒有看到OP所詢問的實際代碼的情況下,無法判斷這是否是問題。 – jfriend00

回答

1

既然你沒有張貼代碼設置.slideUp()方法等等。我假設你有這樣的事情:

$(function)() { 

    $('.class').slideUp(300); 
    $('.wrapper').load('someurl.html'); // this loads some elements with .class 
    // these elements won't get slideUp applied because they are not in the DOM at the time of the slideUp call 


)}; 

您需要設置事件/功能,在負載通話返回:

$('#result').load('ajax/test.html', function() { 
    //apply events to new elements 
    $('.class').slideUp(300); // this would be inside a click event I'm assuming 
}); 

或者正如評論中提到的那樣...您可以(應該)使用可以處理委派的.on。我的觀點是,試圖幫助你明白爲什麼沒有應用事件

+0

那麼這個答案對我的作品,現在 - 感謝 - 所以我會當我被允許接受它! – Xhynk

+0

-however,我會考慮使用'.on' – Xhynk