javascript - Using multiple selectors with each having different events -
this question has answer here:
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
Post a Comment