Search code examples
google-closuregoogle-closure-library

how to hide/show dom element in google closure


domA.style.display = "none"; domA.style.display = "block;

I could not find such functions in the library, but I guess they must have it somewhere.


Solution

  • <html>
    <head>
    <script src="http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js" type="text/javascript"></script>
    <script language="JavaScript">
        goog.require('goog.style');
    </script>
    </head>
    <body>
       <div id="myElement">test</div>
    </body>
    </html>
    <script> 
        goog.style.setStyle(goog.dom.$("myElement"), "display", "none");
        // or
        goog.style.showElement(goog.dom.$("myElement"), false);
    </script>