Link to home
Start Free TrialLog in
Avatar of MJ
MJFlag for United States of America

asked on

Detect using JS Only If element exists on Page and Is Visible

How would I detect if this element is on the current page and visible? Using JavaScript and NOT jQuery.

<p><strong>Before you Start</strong></p>

Open in new window


I'm fairly sure this function will suffice with detecting if visible.

    function _dtmIsVis(elem) {
        if (elem === null) {
            return false;
        }
        return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length);
    };

Open in new window


Thanks!
ASKER CERTIFIED SOLUTION
Avatar of MJ
MJ
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial