Your code sets the containing block to display: none. After that, it doesn't matter that the internal <div>
is "display: block".
Your diagnostic item reset technique is erroneous. If you use something like a Chrome or Firebug debugger, you will see that your “ShowThis” element really has “display: block” in its “style” attribute. However, it is not displayed because all of its parent elements (including the <body>
) are still "display: none".
edit I think the problem is probably related to the order in which page elements are displayed as a result of "getElementsByTagName ()". If you reach the parent after the children, then they will be set to "display: none" after they are set to "display: block".
change again - confirmed. Elements are returned from "getElementsByTagName ()" in the reverse order that they appear in HTML. So the last element that your code sees in the outer loop is the <div>
container for the "ShowThis" <div>
.
edit again, oh, I see - you're coming back! Durr. If you go through the node list, it should work.
source share