javascript - Using multiple selectors with each having different events -


i need this:

$("#household").children().change(function(){     alert("changed"); });  $('.ui-icon.ui-icon-closethick.delete').click(function(){     alert("changed"); }); 

turned this:

$("#household").children().change || $('.ui-icon.ui-icon-closethick.delete').click(function(){     alert("changed"); }); 

i know bottom code isn't correct, hoping explains mean. want alert executed if #household.children() changed , .ui-icon.ui-icon-closethick.delete clicked, without writing code twice.

you can achieve putting common logic in own function called both events:

function changed() {     console.log('changed') }  $("#household").children().change(changed); $('.ui-icon.ui-icon-closethick.delete').click(changed); 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -