I would like to know how I can do this...
function action(param)
{
$(body).param('Blah');
}
action('append');
If you understood me, is there any way of that happening?
I would like to know how I can do this...
function action(param)
{
$(body).param('Blah');
}
action('append');
If you understood me, is there any way of that happening?
Functions are first-class objects in JavaScript. You should just pass in the function, and use apply
to invoke it on $('body')
, rather than passing in a string which may or may not actually point to a function:
function action(fn) {
fn.call($('body'), 'Blah');
}
action($.fn.append);