Skip to content

Instantly share code, notes, and snippets.

@suntong
suntong / gist:dad3c1c19936861d90a5
Last active August 29, 2015 14:20
jQuery Checkbox :checked Selector: Travers the selected checkboxes
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>checked demo</title>
<style>
div {
color: red;
}
</style>
body, input {
font-family:Calibri, Arial;
margin:0px
}
h1 {
margin:0 0 0 20px
}
html, body, #container {
height:100%
}
<title>Multiple Checkbox Select/Deselect - DEMO</title>
<h2>Multiple Checkbox Select/Deselect - DEMO</h2>
<table border="1">
<tbody>
<tr>
<th>
<input type="checkbox" id="selectall">
</th>
<th>Cell phone</th>
$(function () {
$("#selectall").click(function () {
$('.case').prop('checked', this.checked);
});
$(".case").click(function () {
if ($(".case").length == $(".case:checked").length) {
$("#selectall").prop("checked", true);
} else {
$("#selectall").prop("checked", false);
}
<html>
<head>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">
<!-- Include roboto.css to use the Roboto web font, material.css to include the theme and ripples.css to style the ripple effect -->
<link href="dist/css/roboto.min.css" rel="stylesheet">
<link href="dist/css/material.min.css" rel="stylesheet">
<link href="dist/css/ripples.min.css" rel="stylesheet">
@suntong
suntong / gist:3539307ef77ddee95f10
Last active August 29, 2015 14:23
Go Template Example
package main
import (
"bytes"
"os"
"text/template"
)
type Person struct {
Name string //exported field since it begins with a capital letter
@suntong
suntong / Yaml-Example.go
Created June 15, 2015 04:21
Yaml Example
package main
import (
"fmt"
"log"
"gopkg.in/yaml.v2"
)
type Config struct {
$ easygen test/commandlineFlag
package easygenapi
import (
"flag"
"fmt"
"os"
)
////////////////////////////////////////////////////////////////////////////
// !!! !!!
// WARNING: Code automatically generated. Editing discouraged.
// !!! !!!
package main
import (
"flag"
"fmt"
"os"