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? Quote Link to comment 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'; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.