MoreLesson 235Free preview
Find Hidden Element
This lesson is part of How To · All levels
Summary
Determining whether a hidden element requires a review of some conditions, as the element can be hidden by display, visibility, hidden attributes, or by its parent. The property element.style only reads inline style, so getComputedStyle is more reliable for finding out the final style. For simple cases, checking out offsetParent or hidden attributes can also help.
Key points
- Element.style.display only reads inline style, not rules from the stylesheet
- GetComputedStyle returns the final style value that applies to the element
- Elements with visibility: hidden remain space-occupied, as opposed to display: none
- The element can also be hidden because the parent is hidden.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.