2013-10-29 291 views
-1

我發現了一個工作代碼,它從javascript調用了一個jquery函數。我想在頁面加載時做同樣的事情。下面是我的代碼。從javascript調用jquery方法

$(".wheel-button").wheelmenu({ 
    trigger: "", 
    animation: "fly", 
    animationSpeed: "fast" 
    }); 

請幫我調用頁面加載屬性的wheelmenu()jquery函數。

+0

貌似'wheelmenu'是在這種情況下的一個插件,它只有意味着從jQuery對象中調用。 – Phil

+0

是的,wheelmenu是jquery.wheelmenu.js.i中的一個函數,希望在頁面加載時或在id #center元素可見後執行的代碼。 –

+0

我可能誤解了你的問題。 – Phil

回答

1
$(document).ready(function(){ 

function run(){ 

$(".wheel-button").wheelmenu({ 
    trigger: "", 
    animation: "fly", 
    animationSpeed: "fast" 
    }); 
} 
run(); 
}); 

就是這樣..

+0

這段代碼越來越接近我的需求了,因爲我是jquery的初學者,可以看看jquery.wheelmenu.js –

2

使用 「準備就緒」 事件處理程序。一旦文檔完全加載,它就會啓動。

$(document).ready(function() { 
$(".wheel-button").wheelmenu({ 
    trigger: "", 
    animation: "fly", 
    animationSpeed: "fast" 
    }); 
}); 

見就緒功能在這裏:

http://api.jquery.com/ready/

1

嘗試類似的$(document).ready()$(handler)short hand

$(function() { 
    $(".wheel-button").wheelmenu({ 
     trigger: "", 
     animation: "fly", 
     animationSpeed: "fast" 
    }); 
});