5

[GopherJS] Get head Element in HTML Document

 2 years ago
source link: http://siongui.github.io/2016/03/13/gopherjs-get-head-element-in-html-document/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

[GopherJS] Get head Element in HTML Document

March 13, 2016

Access head element in HTML document via getElementsByTagName and GopherJS:

head := js.Global.Get("document").Call("getElementsByTagName", "head").Call("item", 0)

equivalent to the following JavaScript code:

var head = document.getElementsByTagName("head")[0];

Tested on: Ubuntu Linux 15.10, Go 1.6.

References:

[2]javascript - document.head v. document.getElementsByTagName("head")[0] - Stack Overflow

[3]Element.getElementsByTagName() - Web APIs | MDN

[4]HTMLCollection - Web APIs | MDN


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK