我试图将“term”传递给外部函数。如何自动将jQuery函数参数传递给外部函数?
$('#item').terminal(function(command, term) {
我一直能够做到这一点的唯一方法是通过在函数中传递“term”。
myfucntion(term, 'hello world');
有没有一种方法,我可以做到这一点,而不必每次都通过它?
编辑:
$(function() {
$('#cmd').terminal(function (command, term) {
switch (command) {
case 'start':
cmdtxt(term, 'hello world');
break;
default:
term.echo('');
}
}, {
height: 200,
prompt: '@MQ: '
});
});
function cmdtxt(term, t) {
term.echo(t);
}
我不清楚你在做什么。请提供更完整的示例。 – 2013-04-05 12:57:03
我加了我的完整代码。正如你所看到的,我将外部函数传递给外部函数,可以称之为回声函数。 – Shylor 2013-04-05 13:02:02