rockinaway Posted October 26, 2007 Share Posted October 26, 2007 I have used document.getElementById(id).getElementByTagName('li').length to get me the total number of values I have in a list.. How can I loop through all the values and apply a class change to them? Link to comment https://forums.phpfreaks.com/topic/74925-looping-through-an-array/ Share on other sites More sharing options...
emehrkay Posted October 27, 2007 Share Posted October 27, 2007 do it one step at a time var list_items = document.getElementById(id).getElementByTagName('li'); //this is your array of li elements var li_count = list_items.length; you really dont need the length to loop through if you use an for in loop for(var x in list_items){ list_items[x].className = 'new_class_name'; } Link to comment https://forums.phpfreaks.com/topic/74925-looping-through-an-array/#findComment-379288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.