[GopherJS] Check nodeType of DOM Element


Check node type (nodeType) of DOM element via GopherJS.

import "github.com/gopherjs/gopherjs/js"

element := js.Global.Get("document").Call("getElementById", "foo")
nodeType := element.Get("nodeType").Int()
if nodeType == 1 {
      // element node
}
if nodeType == 3 {
      // text node
}
if nodeType == 8 {
      // comment node
}

See [3] for more nodeType.


References:

[1]GopherJS - A compiler from Go to JavaScript (GitHub, GopherJS Playground, godoc)
[2]
[3]Node.nodeType - Web APIs | MDN