Created
April 9, 2015 08:59
-
-
Save shakhal/fc55a8aad740d9e595f8 to your computer and use it in GitHub Desktop.
Toggle all checkboxes in column of HTML table by TH header checkbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("th input[type='checkbox']").on("click",function(){ | |
var col = $(this).parent().children().index($(this)); | |
var checked = $(this).is(":checked"); | |
$(this).closest("table").find("tr td:nth-child("+col+") input[type=checkbox]").prop("checked", checked); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment