How to check if an input element is hidden?

Viewed 38565

How can you check if an input element is hidden?

4 Answers

HTMLElement.hidden should return true if it owns the hidden attribute.

document.querySelector('h1').hidden === true

I hope it helps.

The getAttribute() method of the Element interface returns the value of a specified attribute on the element. If the given attribute does not exist, the value returned will either be null or "" (the empty string);

for a hidden element, you can check the type attribute of element.

$('#myElement').getAttribute('type')=='hidden'
Related