[jQuery] duplicating functions in a loop?
Does anyone know how I can duplicate an onclick function X amount of
times? Here is what I'm trying to do, but this doesn't work. I'd like
to avoid duplicating this function 5 times like I have now.
Any suggestions?
total_slides = 5;
for(var i=0;i<=total_slides;i++){
$("li#tabLink"+i+" a").click(function(){
$("div.tabContent:visible").hide();
$("li.tabLink").removeClass('active');
$("div#tab"+i).show();
$("li#tabLink"+i).addClass('active');
document.getElementById('rememberTab').value = i;
document.getElementById('rememberTab').checked = false;
write_current_tab(i);
stop_all();
});
}
Thanks
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/