how to hide/show dom element in google closure

romerun picture romerun · Dec 23, 2009 · Viewed 8.2k times · Source

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.

Answer

andres descalzo picture andres descalzo · Dec 29, 2009
<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>