<html>
<head>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title></title>
</head>
<body>
<div class="bin-desc"></div>
<table id="MyTable" cellspacing="0">
<thead>
<tr>
<th class="text-bottom">MyTable</th>
<th><!--Column spacer --></th>
<th><span>column 1</span></th>
<th><span>column 2</span></th>
<th><span>column 3</span></th>
<th><span>column 4<br>one box</span></th>
<th><span>column 5<br>one box</span></th>
<th><span>column 6</span></th>
<th><span>column 7</span></th>
<th><span>column 8<br>required</span></th>
<th><span>column 9<br>optional</span></th>
</tr>
</thead>
<tbody>
<tr class="single-choice-box opt-req-box">
<td><a>email1@domain.com</a>
</td>
<td><!--Column spacer --></td>
<td><input type="checkbox" name="" value="1" /></td>
<td><input type="checkbox" checked="true" name="" value="2" /></td>
<td><input type="checkbox" checked="true" name="" value="3" /></td>
<td><input data-type="oneBox" class="oneBox"type="checkbox" name="" value="4" /></td>
<td><input data-type="oneBox" class="oneBox" type="checkbox" name="" value="5" /></td>
<td><input type="checkbox" checked="true" name="" value="6" /></td>
<td><input type="checkbox" checked="true" name="" value="7" /></td>
<td><input type="checkbox" data-type="required" value="8" /></td>
<td><input type="checkbox" data-type="optional" value="9" /></td>
</tr>
<tr>
<td ><a>email2@domain.com </a></td>
<td><!--Column spacer --></td>
<td><input type="checkbox" name="" value="1" /></td>
<td><input type="checkbox" checked="true" name="" value="2" /></td>
<td><input type="checkbox" checked="true" name="" value="3" /></td>
<td><input data-type="oneBox" class="oneBox"type="checkbox" name="" value="4" /></td>
<td><input data-type="oneBox" class="oneBox" type="checkbox" name="" value="5" /></td>
<td><input type="checkbox" checked="true" name="" value="6" /></td>
<td><input type="checkbox" checked="true" name="" value="7" /></td>
<td><input type="checkbox" data-type="required" value="8" /></td>
<td><input type="checkbox" data-type="optional" value="9" /></td>
</tr>
<tr>
<td><a>email3@domain.com</a>
</td>
<td><!--Column spacer --></td>
<td><input type="checkbox" name="" value="1" /></td>
<td><input type="checkbox" checked="true" name="" value="2" /></td>
<td><input type="checkbox" checked="true" name="" value="3" /></td>
<td><input data-type="oneBox" class="oneBox"type="checkbox" name="" value="4" /></td>
<td><input data-type="oneBox" class="oneBox" type="checkbox" name="" value="5" /></td>
<td><input type="checkbox" checked="true" name="" value="6" /></td>
<td><input type="checkbox" checked="true" name="" value="7" /></td>
<td><input type="checkbox" data-type="required" value="8" /></td>
<td><input type="checkbox" data-type="optional" value="9" /></td>
</tr>
<tr>
<td><a>email4@domain.com</a>
</td>
<td><!--Column spacer --></td>
<td><input type="checkbox" name="" value="1" /></td>
<td><input type="checkbox" checked="true" name="" value="2" /></td>
<td><input type="checkbox" checked="true" name="" value="3" /></td>
<td><input data-type="oneBox" class="oneBox"type="checkbox" name="" value="4" /></td>
<td><input data-type="oneBox" class="oneBox" type="checkbox" name="" value="5" /></td>
<td><input type="checkbox" checked="true" name="" value="6" /></td>
<td><input type="checkbox" checked="true" name="" value="7" /></td>
<td><input type="checkbox" data-type="required" value="8" /></td>
<td><input type="checkbox" data-type="optional" value="9" /></td>
</tr>
</tbody>
</table>
</body>
</html>
div.bin-desc{
margin: 30px;
text-decoration: underline;
text-align: center;
}
table thead tr th.text-bottom{
vertical-align: bottom;
text-align: left;
}
table thead tr th {
text-align: center;
vertical-align: top;
}
table thead tr td {
vertical-align: top;
width: 60px;
word-wrap: break-word;
white-space: normal;
}
table tr td:not(:first-child) {
text-align: center;
}
table td {
border-bottom: 1px solid #CCC;
}
table tr:first-child td {
border-top: 1px solid green;
vertical-align: middle;
}
table tr:last-child td {
border-bottom: 1px solid green;
}
$(document).ready(function(context){
// Check-all Checkboxes in Group
$('input[data-action=check-all]', context).on('click', function() {
var $id = $(this).attr('id');
var _checkboxes = context.find('input[data-grp-id='+ $id + ']');
if ($(this).attr('checked')) {
_checkboxes.attr('checked', 'true');
} else {
_checkboxes.removeAttr('checked');
}
});
// On checkbox click, check if check-all state needs to be altered
$(context).on('click', 'input[data-action=check-group]', function(event) {
var _parentCheckbox = $('input#'+ $(this).data('grp-id'), context);
if (_parentCheckbox) {
var _checkboxes = $('input[data-grp-id='+ $(_parentCheckbox).attr('id')+ ']', context);
if (_checkboxes.not(':checked').size() == 0) {
_parentCheckbox.attr('checked','checked');
} else if (_checkboxes.not(':checked').size() <= _checkboxes.size()) {
_parentCheckbox.removeAttr('checked');
}
}
});
// End Script
// Optional and Required Checkboxes
$("input[type='checkbox'][data-type='optional']").on('change', function() {
var $this = $(this);
var $row = $this.closest('.opt-req-box');
if ($this.is(':checked')) {
$row.find("input[type='checkbox'][data-type='required']").prop('checked', true);
}
});
$("input[type='checkbox'][data-type='required']").on('change', function() {
var $this = $(this);
var $row = $this.closest('.opt-req-box');
if ($row.find("input[type='checkbox'][data-type='optional']").is(':checked')
&& !$this.is(':checked')) {
$row.find("input[type='checkbox'][data-type ='optional']").prop('checked', false);
}
});
// End Script
// Select Only One Two Checkboxes
$(".oneBox").on('change', function() {
var $this = $(this);
var $row = $this.closest('.single-choice-box');
var checkedAlready = $this.prop('checked');
$row.find('.oneBox').each(function(i, e) {
var $checkbox = $(e);
$checkbox.prop('checked', false);
});
if (!checkedAlready && !$this.prop('checked')) {
$this.prop('checked', true);
}
});
// End Script
});
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |