Created
September 3, 2013 05:17
-
-
Save umidjons/6419933 to your computer and use it in GitHub Desktop.
Select table rows that contain checked checkbox using jQuery
This file contains 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
<!doctype html> | |
<html lang="en-US"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Rows that contain checked checkbox</title> | |
</head> | |
<body> | |
<table class="_tm"> | |
<thead>...</thead> | |
<tbody> | |
<tr> | |
<td><input type="checkbox" name="sel" id="chk"/></td> | |
<td>text 1</td> | |
</tr> | |
<tr> | |
<td><input type="checkbox" name="sel" id="chk"/></td> | |
<td>text 2</td> | |
</tr> | |
<tr> | |
<td><input type="checkbox" name="sel" id="chk"/></td> | |
<td>text 3</td> | |
</tr> | |
</tbody> | |
<tfoot>...</tfoot> | |
</table> | |
<script type="text/javascript" src="/js/jquery-1.10.2.js"></script> | |
<script type="text/javascript"> | |
jQuery( document ).ready( function ( $ ) | |
{ | |
var selectedRows = $( 'table._tm' ).find( 'tbody' ) // select table body and | |
.find( 'tr' ) // select all rows that has | |
.has( 'input[type=checkbox]:checked' ) // checked checkbox element | |
console.log( 'selectedRows:', selectedRows ); | |
} ); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hai table._tm what does that mean?