[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
}
References:
[1] | GopherJS - A compiler from Go to JavaScript (GitHub, GopherJS Playground, ) |
[2] |
[3] | Node.nodeType - Web APIs | MDN |