I am wondering if there is a way instead of listing what happens when each individual item is clicked, for example:
$('#object1').click(function(){ stuff += object1amount };
$('#object2').click(function(){ stuff += object2amount };
$('#object3').click(function(){ stuff += object3amount };
$('#object4').click(function(){ stuff += object4amount };
$('#object5').click(function(){ stuff += object5amount };
I can have:
$('LIST OF HTML ELEMENTS').click(function(){ stuff += this.amount };
where 'this' is the context of any HTML element that has been clicked.
source
share