I have two elements. I have to do same code logic for one element's click and another element's change. How can I combine these two to avoid code duplication. I am looking for a solution other than calling a same function from both the events.
$( "element1" ).change(function(){
//some stuff here
});
$( "element2" ).click(function(){
//same above stuff here
});
$("element1").change(sharedFunction)and$("element2").click(sharedFunction)