Hello,
I have the following code:
$('#form_field, #button').bind('change click', function() {
// take action
}
It works fine. However, I want to trigger the same action when 'change' is used for '#form_field' and 'click' for '#button' (not when 'click' is used for '#form_field').
I know that can be done using the following code:
$('#form_field').bind('change', function() {
// take action
}
$('#button').bind('click', function() {
// take action
}
However, I do not want to repeat all the code that is inside the function (// take action). It would look ineffective and I will need to edit it twice every time I make changes to it.
Any ideas?
Thanks in advance