If you're using .trigger()
you have the advantage of being able to pass additional parameters, whereas .click()
must be called without any.
Taken from the documentation:
$('#foo').bind('custom', function(event, param1, param2) {
alert(param1 + "
" + param2);
});
$('#foo').trigger('custom', ['Custom', 'Event']);
'Custom'
and 'Event'
are being passed to the event handler as param1
and param2
respectively
Besides that, the .click()
is unlike other functions that implement get / set based on the number of arguments, because it implements trigger / set instead. Using a dedicated .trigger()
, to me, is more logical.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…