I have the following finctions in my script and they do the same thing. How may I combine them?
$('.AddOne').live('click', function(){
$('.saveGroup').show();
});
$('#PhoneNumbersSelectms2side__sx option').dblclick(function(){
$('.saveGroup').show();
});
$('.AddAll').live('click', function(){
$('.saveGroup').show();
});
The
clickanddblclickevent methods each take a callback function as their first argument. In javascript functions are variables. you create a function, and pass it to the callbacksYou can further simplify this code by combining the live selectors like this:
Finally, if you are using jquery 1.7.x you should use the new
onevent methods instead oflive. Your new code would look like this: