1## jQuery Bindings for [GopherJS](http://github.com/gopherjs/gopherjs) 2 3## Install 4 5 $ go get github.com/gopherjs/jquery 6 7### How To Use 8 9welcome.html file: 10```html 11<!doctype html> 12<html lang="en"> 13<head> 14 <meta charset="utf-8"> 15 <title>Welcome to GopherJS with jQuery</title> 16 <script src="resources/jquery-2.1.0.js"></script> 17</head> 18<body> 19 <input id="name" type="text" value="" placeholder="What is your name ?" autofocus/> 20 <span id="output"></span> 21 <script src="welcome.js"></script> 22</body> 23</html> 24``` 25 26welcome.go file: 27 28```go 29package main 30 31import "github.com/gopherjs/jquery" 32 33//convenience: 34var jQuery = jquery.NewJQuery 35 36const ( 37 INPUT = "input#name" 38 OUTPUT = "span#output" 39) 40 41func main() { 42 43 //show jQuery Version on console: 44 print("Your current jQuery version is: " + jQuery().Jquery) 45 46 //catch keyup events on input#name element: 47 jQuery(INPUT).On(jquery.KEYUP, func(e jquery.Event) { 48 49 name := jQuery(e.Target).Val() 50 name = jquery.Trim(name) 51 52 //show welcome message: 53 if len(name) > 0 { 54 jQuery(OUTPUT).SetText("Welcome to GopherJS, " + name + " !") 55 } else { 56 jQuery(OUTPUT).Empty() 57 } 58 }) 59} 60``` 61 62Compile welcome.go: 63 64 $ gopherjs build welcome.go 65 66 67### Tests 68 69In the "tests" folder are QUnit Tests, run the server with: 70 71"go run server.go" and open a browser: http://localhost:3000 72 73The relevant QUnit Test cases are defined in the test/index.go file. 74 75### Sample Apps ported from Javascript/Coffeescript to GopherJS 76 77Look at the Sample Apps to find out what is working and how. Any feedback is welcome ! 78 79- [TodoMVC, jQuery Example](https://github.com/gopherjs/todomvc) 80- [Flappy Bird, Math Edition](https://github.com/rusco/flappy-math-saga) 81- [Simple Tabata Timer](https://github.com/rusco/tabata-timer) 82- [QUnit](https://github.com/rusco/qunit) 83 84 85### Status 86 87The normal DOM / Ajax / Deferreds Api is done and can be considered stable. 88Please look up the index.go file in the test folder to see how it works. 89