Create some dynamic content
We can start with a pretty simple example:
func main() {
hogosuru.Init()
c, _ := console.New()
// we get the current document
if doc, err := document.New(); hogosuru.AssertErr(err) {
//we get the current body
if body := doc.Body_(); hogosuru.AssertErr(err) {
//we empty all things in body
body.SetTextContent("")
//we create a div
if div, err := htmldivelement.New(doc); hogosuru.AssertErr(err) {
//we create a button and a span with text
if span, err := htmlspanelement.New(doc); hogosuru.AssertErr(err) {
span.SetTextContent("Please click on this button")
span.SetID("spanwithtext")
div.Append(span.Element)
}
//we create a button and a span with text
if button, err := htmlbuttonelement.New(doc); hogosuru.AssertErr(err) {
button.SetTextContent("click on this button")
button.SetID("mycustombutton")
button.OnClick(func(e event.Event) {
c.Debug("You click on this button")
})
div.Append(button.Element)
}
//we attach div to the body
body.Append(div.Element)
}
}
}
ch := make(chan struct{})
<-ch
}


Last updated