2013-10-29 115 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" 
    }); 
});