C.O.D.E.N.A.M.E
04-03-2008, 02:09 PM
I am trying to iterate through a unordered list (jquery), but when I find the ninth element in this array (the LIs), I want to restart with i again from 0, that way item 0 and item 10 get the same class="menu_0", item 1 and item 11 get the same class="menu_1", and so on. I know I need another loop inside but how ...
This is what I got
jQuery(document).ready(
function(){
jQuery("#menu").find("li").each(function(i){
jQuery(this).addClass("menu_"+i);
jQuery(this).find("a").attr("rel","styles_"+i)
if (i==0)
jQuery("title").before("<link rel='stylesheet' type='text/css' href='styles_"+i+".css' title='styles_"+i+"' media='screen' />");
else
jQuery("title").before("<link rel='alternate stylesheet' type='text/css' href='styles_"+i+".css' title='styles_"+i+"' media='screen' />");
});
});
Thanks for any assistance!!
This is what I got
jQuery(document).ready(
function(){
jQuery("#menu").find("li").each(function(i){
jQuery(this).addClass("menu_"+i);
jQuery(this).find("a").attr("rel","styles_"+i)
if (i==0)
jQuery("title").before("<link rel='stylesheet' type='text/css' href='styles_"+i+".css' title='styles_"+i+"' media='screen' />");
else
jQuery("title").before("<link rel='alternate stylesheet' type='text/css' href='styles_"+i+".css' title='styles_"+i+"' media='screen' />");
});
});
Thanks for any assistance!!