Programming/Javascript

[jQuery]전체 선택

옥수수빵 2020. 2. 27. 15:15
728x90
$(function() {
	$("#check-all").on("click", function(e) {
		e.preventDefault();
		$(".chks").trigger("click");
	});
});
<table>
	<tr>
		<th><a href="#" id="check-all">check all</a></th>
	</tr>
	<tr>
		<td><input type="checkbox" class="chks"></td>
	</tr>
	<tr>
		<td><input type="checkbox" class="chks"></td>
	</tr>
	<tr>
		<td><input type="checkbox" class="chks"></td>
	</tr>
</table>

반응형