14
[Golang] Remove All Child Nodes of a DOM Element by GopherJS
source link: http://siongui.github.io/2016/01/31/go-remove-all-children-of-dom-element-by-gopherjs/
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.
[Golang] Remove All Child Nodes of a DOM Element by GopherJS
January 31, 2016
In JavaScript, we can remove all child nodes of a DOM element [4] by:
while (elm.hasChildNodes()) { elm.removeChild(elm.lastChild); }
In Golang, we can do the same by GopherJS:
import "github.com/gopherjs/gopherjs/js" for elm.Call("hasChildNodes").Bool() { elm.Call("removeChild", elm.Get("lastChild")) }
Tested on: Ubuntu Linux 15.10, Go 1.5.3, Chromium Version 48.0.2564.82 Ubuntu 15.10 (64-bit).
References:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK