Search code examples
dojohiddenvisible

Using Dojo 1.9 how do you check if an element is visible?


I hide or show a field with the following code:

Show element:

style.set(dojo.byId('fTypeId'), 'display', 'block');

Hide element:

style.set(dojo.byId('fTypeId'), 'display', 'none');

How can I test if this element is showing?


Solution

  • Try :

    require(["dojo/dom-style"], function(domStyle){
        var isVisible = (domStyle.get("yourNodeId", "display") !== "none");
    });