I ended up using this. I liked it much better than my previous
solution (passing in "this" and then stripping the digit out in the
handler).

$.each( [0,1,2,3,4], function(index, num) {
    $("#port"+num).click(function() { bigchart(num); });
});

This one is easy for me to read, comprehend, and maintain. And having
it around in my code will be a good way for me to keep the
jQuery .each in mind.

This next one is obviously a work of JavaScript art (as opposed to the
former, which is a more jQuery solution). Does anyone want to explain
it?

 for ( i=0;i<5;i++ ) {
    (function(num) {
        $("#port"+num).click(function() { bigchart(num) });
    })(i);
 }

Reply via email to