Skip to content

HTMLElement.isShown method

HTMLElement › isShown

Official

Returns whether this element is shown, when the element is attached to the DOM and none of the parent and ancestor elements are hidden with display: none.

Exception: Does not work on <body> and <html>, or on elements with position: fixed.

Signature:

isShown(): boolean

Returns: booleantrue if the element is shown, false otherwise.

Example:

const element = document.body.createEl('p');
console.log(element.isShown()); // true
element.hide();
console.log(element.isShown()); // false