MFa*_*oqi 4 jquery global function parent-child
如何在jquery中声明一个全局函数,我如何使用jquery的load()函数从该页面上某个div中加载的页面调用它.
第一个子页面的功能很简单
+-----------------------------------------------+ | main links | +-----------------------------------------------| | +-------------------------------------------+ | | |1st sub page (myfun function is here) | | | +-------------------------------------------+ | | | +---------------------------------------+ | | | | | | | | | | | | | | | | | | | | | | | mybutton clicked myfun called | | | | | | | | | | | +---------------------------------------+ | | | +-------------------------------------------+ | +-----------------------------------------------+
但是当我点击时,没有任何反应......这里都是功能
myfun
myfun(tab_index, acc_id){
alert(tab_index +" | +" acc_id);
}
Run Code Online (Sandbox Code Playgroud)
为myButton
$("#mybutton").click(function(){
var $bottomLineBtn = $(this);
$bottomLineBtn.parent().myfun('2','43234');
})
Run Code Online (Sandbox Code Playgroud)
有人可以帮助我..它太难找到解决方案..我一直在寻找3个小时......
================================================== ================================
更新
这是详细的场景
id=menu和其他id=subpage1,#subpage1.#menu2和#subpage2#subpage2通过只取一个参数.... 自动加载页面....这是listmenu的id.这个脚本是......
$("#menu2 li").click(function(){
$("#subpage2").load($(this).attr('page_link'));
}
}).filter('#menu2 li:eq(0)').click();
在加载的页面中.在极端的底部,我使用2个按钮,一个按钮工作正常,它调用上面的功能并更改值li:eq(1)..我这样做.
$("#bottom_bar #backbtn").click(function(){
var $bottomLineBtn = $(this);
$bottomLineBtn.parent().parent().parent().find('#menu2 li:eq(1)').click();
})
...但是其他按钮不起作用.我想调用属于某些div的函数#subpage1.但无法访问它们.我只放了一个函数,在上面的$("#menu2 li").click(function(){函数旁边.
myfun(tab_index, acc_id){
alert(tab_index +" | +" acc_id);
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何从加载的第二个按钮调用此功能 #subpage2
上面的场景是否有场景..请尝试理解我...我的描述不是很好...