function onBodyLoad()
{
document.addEventListener("deviceready",onDeviceReady,false);
//for testing in safari only, comment out for deploy to iphone with phonegap
$(document).ready(function(){
loadPage('mainmenu', 'Home');
$('#menus').toggle();
//I have a nested div in this index.html file with id=menubottbutt
$("div").delegate("#menubottbutt","click",toggleMenu());
$("div").delegate(".menuitem","click",toggleMenu());
});
}
在 body 元素中我有这个
当它运行并点击委托行时,我收到错误* * TypeError: 'undefined' is not a function (evaluating'$("div").delegate("#menubottbutt","click",toggleMenu())' )
当然,我有上面定义的方法 toggleMenu,它在从其他地方调用时有效。看起来像这样 `function toggleMenu() {
$('#menus').toggle('slow');
$('#menubottbutt').toggleClass('pressed');
} `
谢谢
PS这是我到目前为止所拥有的:在我的onBodyLoad中,我将使用 $("#menubottbutt").click(function(){toggleMenu();}); 在其他合适的地方我会打电话给: $(".menuitem").click(function(){toggleMenu();}); 这似乎解决了我的问题,但如果我能让代表工作可能会更好。