O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Changing the CSS style property of an element

In the previous code snippets that we covered, we only considered examples where we accessed the DOM element. Now, let's consider an example where we change an element's CSS style property. We will hide the content inside the primary content div container by changing the value of the div element's display property.

We can save ourselves some typing by aliasing calls to js.Global and the dom package like this: For GopherJS: JS := js.Global For the dom package: D := dom.GetWindow().Document()

In order to change the display property of the primary content div container, we will first need to access the div element, and then change it's display property to the none value.

JavaScript

element = document.GetElementById("primaryContent"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required