[Javascript] See if item is hidden...

Chris T christ at saeweb.com
Tue Jun 22 16:01:39 CDT 2004


> > Of course you could walk up the tree until you hit what would
> > be its parent.
>
> Yes, I had that thought as well. Just was not too sure on how to do
> that, and was hoping for a "clear" solution.

If the "parent" you're looking for would be the first DIV found up the tree,
then it would be REALLY simple.

Actually, I sent something to the list earlier today when I was discussing
getting an element's position and it will apply here. I've made a few
changes to illustrate:

=====================
  var objItem = document.getElementById("Pa21")
  // if it's ID is Pa21 - if not, use whatever
  var objParent = null
  do
   { // Walk up our document tree until we find the DIV you want
    objParent = objItem.offsetParent.tagName
    objItem = objItem.offsetParent
   }
  while(objParent != 'DIV')
=====================

Coming out of the loop, objItem would be the DIV you want and you should be
able to:

alert(objItem.style.display)

If it's not going to be the first DIV, then use some naming convention and
work off of that property instead of the tagName...

Hope that helps,

Chris Tifer




More information about the Javascript mailing list