Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

determining if element is hidden

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a select box within a table and it has a td which is styled to be hidden. As a result, the contents of the td are also hidden. When I do an select element iteration the select elements style.visible property does not provide any info on whether the element is visible on the page or not (i'm assuming the default is inherit). Is there an easy way of determining this other than navigating thought all parents and testing the visible property?

Thanks,
Sanjiv
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not have time to code it, but it is similiar to this: http://radio.javaranch.com/pascarello/2005/01/09/1105293729000.html

Eric
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or this might work:



var test = getElementStyle("id", "visibility", "visibility");

Eric
 
Sanjiv Jivan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately the above code isn't doing what I need.

elem.currentStyle evaluates to true in IE but elem.currentStyle["visible"] returns the String "inherit".

Sanjiv
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
visible is the value, not the style attribute name, it is visibility.

I still do not have time to test it, thought i would point out. If computed style does not work, than you are going to have to loop through the parents checking the visible state like I do to find the position in that link.

Eric
 
Sanjiv Jivan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, that was a typo in my previous post. I did pass 'visibility' and not 'visible', and the function returned "inherit".

Sanjiv
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic