[GopherJS] Set/Get DOM CSS


Example - Set or Get CSS property of DOM element via GopherJS.

GopherJS Set DOM CSS

element := js.Global.Get("document").Call("getElementById", "foo")
element.Get("style").Set("left", "50px")

GopherJS Get DOM CSS

element := js.Global.Get("document").Call("getElementById", "foo")
// cast as int
element.Get("style").Get("offsetWidth").Int()
// cast as string
element.Get("style").Get("offsetWidth").String()

References:

[1]GopherJS - A compiler from Go to JavaScript (GitHub, GopherJS Playground, godoc)
[2]
[3][GopherJS] Insert CSS Dynamically