我对jquery已经有3个星期了,并且已经在工作中加入了它(时间压力)。我已搜索但未找到任何答案,因为我可能不知道如何 word 搜索。
好的,请点击:
我正在使用位于http://www.filamentgroup.com/examples/menus/flat.php
的filamentgroup.com的菜单放置系统我在我的文件中调用了这样的函数:
$(document).ready(function(){
$('#lbOptionsButton').menu({
content: $('#lbOptionsMenu').html()
});
});
在(script src)fg.menu.js文件中,有一个部分包含:
this.chooseItem = function(item){
menu.kill();
// edit this for your own custom function/callback:
$('#menuSelection').text($(item).text());
location.href = $(item).attr('href');
};
但是,我不想在该代码中编写我的函数。我想它只需返回$(item)。我怎么称它为所以我可以在我写的任何其他函数中使用$(item)?即ajax等。
提前感谢您的帮助。
答案 0 :(得分:0)
如果您不想在该代码块中编写函数,那么从那里调用 您的函数如何,然后在任何地方定义您的函数。所以,
this.chooseItem = function(item){
menu.kill();
// edit this for your own custom function/callback:
$('#menuSelection').text($(item).text());
location.href = $(item).attr('href');
MyFunction($(item));
};
this.chooseItem = function(item){
menu.kill();
// edit this for your own custom function/callback:
$('#menuSelection').text($(item).text());
location.href = $(item).attr('href');
MyFunction($(item));
这不是你想要的吗?