1
0
mirror of https://github.com/taigrr/wasm-experiments synced 2025-01-18 04:03:21 -08:00
2019-09-04 22:31:34 +02:00

28 lines
505 B
Go

package main
import (
"syscall/js"
)
var document js.Value
func init() {
document = js.Global().Get("document")
}
func main() {
document.Set("appendText", js.FuncOf(appendText))
// Prevent main from exiting
select {}
}
func appendText(_ js.Value, _ []js.Value) interface{} {
msg := document.Call("getElementById", "input").Get("value").String()
p := document.Call("createElement", "p")
p.Set("innerHTML", msg)
document.Call("getElementById", "target").Call("appendChild", p)
return nil
}