how can I use function name passed as argument.
example:
showError('container', 'id', '- message', 'show');
showError('container', 'id', '', 'hide');
function showError(container, id, msg, action)
{
if(action == 'show') {
$('#' + container).show();
$('#' + id).html(msg).show();
}
else {
$('#' + container).hide();
$('#' + id).html(msg).hide();
}
}
In the general case, the bracket notation is good. In your case, use
toggle:or even (as Bergi suggests):
(It uses my own invention, the double-bang
!!, which converts truthy or falsy values to their Boolean equivalents.)