4
[GopherJS] Replace DOM Element in Place
source link: https://siongui.github.io/2016/06/13/gopherjs-replace-dom-element-in-place/
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] Replace DOM Element in Place
June 13, 2016Replace DOM element in place via GopherJS.
Question
Replace element of id foo with another element of id foo2
Answer
import "github.com/gopherjs/gopherjs/js" element := js.Global.Get("document").Call("getElementById", "foo") element2 := js.Global.Get("document").Call("getElementById", "foo2") element.Get("parentNode").Call("replaceChild", element2, element)
See [3] for more information.
References:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK