If it's an event
var handler = 'submit';
$("form").on(handler, function() {
});
If it's a jQuery method
var handler = 'hide';
$('#element')[handler]();
or with a callback
var handler = 'fadeIn';
$('form')[handler](function() {
});
$()
returns an object, so you can use either dot or bracket notation to reference the method, which would be a property of the object etc. so just replace the dot notation with the appropriate bracket notation instead.
If it's an event, you're better of using on()
, but you could also use bracket notation to reference the method directly, like above.