I'm iterating over a bunch of child nodes and checking to see if they are actually visible on the page with this statement:
if(child.offsetWidth == 0 || child.offsetHeight == 0 || child.style.visibility == 'hidden' || child.style.display == 'none'){
child is defined in the loop so that's not an issue.
What is an issue is that elements might not have a style attribute defined and so javascript returns "child.style" not defined.
How do I do a seemingly simple if statement like this without it stopping because something is not defined?
I tried doing this:
if(undefined !== child.style){ var addquery = "child.style.visibility == 'hidden' || child.style.display == 'none'"; }
if(child.offsetWidth == 0 || child.offsetHeight == 0 || addquery){
console.debug(child);
}
But I think addquery is just evaluating to true and not working.