Web API package for use when compling Go to WASM
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

25 lines
523 B

package main
import (
dom "github.com/brettlangdon/go-dom/v1"
console "github.com/brettlangdon/go-dom/v1/console"
document "github.com/brettlangdon/go-dom/v1/document"
)
func onClick(evt *dom.Event) {
elm := evt.GetTarget().ToElement()
console.Log(evt, elm)
}
func main() {
id := "app"
app := document.GetElementById(id)
if app == nil {
console.Error("Could not find element with id %s\r\n", id)
return
}
document.AddEventListener("click", dom.NewEventCallback(onClick))
stop := make(chan int)
<-stop
}