Created
July 1, 2013 17:16
-
-
Save wescleymatos/5902740 to your computer and use it in GitHub Desktop.
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
<html> | |
<head> | |
<title>DEMONSTRAÇÃO: Marcar todas as Check Boxes de uma lista</title> | |
</head> | |
<body> | |
<script> | |
function checkAll(o){ | |
console.log(o); | |
var boxes = document.getElementsByTagName("input"); | |
for (var x=0;x<boxes.length;x++){ | |
var obj = boxes[x]; | |
if (obj.type == "checkbox"){ | |
if (obj.name!="chkAll") obj.checked = o.checked; | |
} | |
} | |
} | |
$('#mark-all').click(function () { | |
$('table').find('input[type=checkbox]').attr('checked', this.checked); | |
}); | |
</script> | |
<form> | |
<table border="1" width="50%"> | |
<tr style="background:#c0c0c0"> | |
<td width="30"><input type="checkbox" name="chkAll" id="mark-all" onClick="checkAll(this)" /></td> | |
<td><b>Nome</b></td> | |
<td><b>Idade</b></td> | |
</tr> | |
<tr> | |
<td><input type="checkbox" name="itm1" /></td> | |
<td>Zé</td> | |
<td>45</td> | |
</tr> | |
<tr> | |
<td><input type="checkbox" name="itm2" /></td> | |
<td>Luiz</td> | |
<td>66</td> | |
</tr> | |
</table> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment