jQuery Event Handler created in loop
<p>So I have a group of events like this:</p>

<pre><code>$('#slider-1').click(function(event){   
        switchBanners(1, true);
});
$('#slider-2').click(function(event){   
        switchBanners(2, true);
});
$('#slider-3').click(function(event){   
        switchBanners(3, true);
});
$('#slider-4').click(function(event){   
        switchBanners(4, true);
});
$('#slider-5').click(function(event){   
        switchBanners(5, true);
});
</code></pre>

<p>And I wanted to run them through a loop I am already running something like this:</p>

<pre><code>for(i = 1; i &lt;= totalBanners; i++){
    $('#slider-' + i).click(function(event){    
            switchBanners(i, true);
    });
}   
</code></pre>

<p>In theory that should work, but it doesnt seem to once I load the document... It doesnt respond to any specific div id like it should when clicked... it progresses through each div regardless of which one I click.  There are more event listeners I want to dynamically create on the fly but I need these first... </p>

<p>What am I missing?</p>
