You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!doctype html><htmllang="en"><head><metacharset="utf-8"><title>Welcome to GopherJS with jQuery</title><scriptsrc="resources/jquery-2.1.0.js"></script></head><body><inputid="name" type="text" value="" placeholder="What is your name ?" autofocus/><spanid="output"></span><scriptsrc="welcome.js"></script></body></html>
welcome.go file:
package main
import"github.com/gopherjs/jquery"//convenience:varjQuery=jquery.NewJQueryconst (
INPUT="input#name"OUTPUT="span#output"
)
funcmain() {
//show jQuery Version on console:print("Your current jQuery version is: "+jQuery().Jquery)
//catch keyup events on input#name element:jQuery(INPUT).On(jquery.KEYUP, func(e jquery.Event) {
name:=jQuery(e.Target).Val()
name=jquery.Trim(name)
//show welcome message:iflen(name) >0 {
jQuery(OUTPUT).SetText("Welcome to GopherJS, "+name+" !")
} else {
jQuery(OUTPUT).Empty()
}
})
}
Compile welcome.go:
$ gopherjs build welcome.go
Tests
In the "tests" folder are QUnit Tests, run the server with: