[jQuery] Break out of a for loop.

[jQuery] Break out of a for loop.


Hi, I am this script:
for (var i=0; i < 6; i++)
{
    $('a#chan'+i).click(function(){
        for (var j=0; j<6; j++)
        {
            $('a#chan'+j).removeClass("chSel");
        }
        $(this).addClass ("chSel");
        channel = i;
    });
}
and I'm trying to get the value of "i" when the link is clicked and
store it in the variable channel. But when I do it, it stores 6 (the
max number) in it. I tried using continue; I tried using i = 7 (to
break the loop, it works in Java, I guess not in Javascript). I really
have no ideas. Anyone can help me real quick with that?
Thanks.