webdesigner25 Posted April 28, 2010 Share Posted April 28, 2010 function changecolor() { this.style.background="red"; for (i=0;i<this.parentNode.length;i++) { if(this.parentNode.childNodes!=this) { this.parentNode.childNodes.style.background=NULL; } }}so what i want to do is to have menu that change color when the item is clicked, and the siblings will be the normal color.this function that i wrote it achieve the first part, but the siblings won't go back to normal. Link to comment Share on other sites More sharing options...
jeffman Posted April 28, 2010 Share Posted April 28, 2010 Think about this expression a little bit:this.parentNode.lengtha parentNode does not have a length property. What would it represent the length of?I suspect you mean this.parentNode.childNodes.lengthFWIW, if you only want to change the background color of an element, you'd do better to modify the backgroundColor property. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.