Jump to content

childNodes


djp1988
 Share

Recommended Posts

Hi, I have the following script that changes the display of a set of div's but I have other divs inside of these divs and because I set the display of all of the div's to none and then only the div triggered to be display:block, the child div's are also hidden, how can I make it so all the div's inside the triggered div also become visible?

function showdiv(div) {	  divs = document.getElementById('info').getElementsByTagName('div');	  if(document.getElementById(div).style.display != "block"){		  for (i = 0; i < divs.length; i++) {			  divs[i].style.display = "none";			  divs[i].style.opacity = "0";			  divs[i].style.filter = "alpha(opacity=0)";		  }		  		  document.getElementById(div).style.display = "block";		  shiftOpacity(div, 500);	  }	 }

I thought of something like:

function showdiv(div) {	  divs = document.getElementById('info').getElementsByTagName('div');	  if(document.getElementById(div).style.display != "block"){		  for (i = 0; i < divs.length; i++) {			  divs[i].style.display = "none";			  divs[i].style.opacity = "0";			  divs[i].style.filter = "alpha(opacity=0)";		  }		  		  document.getElementById(div).style.display = "block";		  		  document.getElementById(div).childNodes.style.display = "block";		  shiftOpacity(div, 500);	  }	 }

Link to comment
Share on other sites

at the start there is one of the div's as display:block' but when you click on a link, the div changes to display:none and the corresponding div is made visible display:blockhow can I treat is as an array ?

Link to comment
Share on other sites

how can I treat is as an array ?
nodz = document.getElementById("my_ID").childNodes;for (var i = 0; nodz[i]; i++) {   if (nodz[i].nodeName.toUpperCase() == "IMG") { // xhtml nodeNames are lower case	  //DO SOMETHING   }}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...