我怎樣才能讓我的jQuery腳本,當一個iframe加載運行一次運行一次?這是我的代碼。請jQuery腳本時的iframe裝載
我的代碼
$(document).ready(function(){
//setup a counter to keep our place and cache a selection to the letter wrappers
var counter = 0,
$chars = $(".test").children();
//setup an interval to animate a letter every so often
setInterval(function() {
//select the current letter wrapper and animate it
$chars.eq(counter).effect("bounce", {times:1}, 500);
//increment the counter so we animate the next letter next time around
counter++;
//check if the counter still relates to an index of the $chars collection
if (counter >= $chars.length) {
counter = 0;
}
}, 250);
});
見我fiddle
我需要它來運行此腳本一次我的id爲playing_song
iframe中加載時。它可以在任何時候。
我試過了。
我一直在使用.ready
嘗試,但顯然它只會顯示它時,它的準備,而不是當它的加載。
我在做的事情是製作一個帶有靜態div的動畫的div。但它不能動態更改,因爲iframe可以隨時加載。此方法僅適用於已刷新的父項。
什麼我後
所有我想要的代碼做的是運行一次當IFRAME playing_song
加載,它隨時可能發生,而且不止一次。
有關如何實現這一點的任何建議?