Is there a way to check if an Element is renderable ?
for example, i want some method to return true on br a div body html etc
but to return false on head style script etc
i tried if(!el.style) return false; but it seems even head and style have .style
is it at all possible or should i just make a list of renderable tagnames ?
I think I have a simple solution. Check which elements have display: none at creation.
JsFiddle here
function isDefaultVisible(domElement) {
var el = document.createElement(domElement.tagName);
return window.getComputedStyle(el,null).getPropertyValue('display') != 'none';
}
All elements can be rendered. It really depends on the browser's default stylesheet. Refer to this great article for more information:
http://mathiasbynens.be/notes/css-hidden-elements
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With