「jquery入門」$(‘table tr’).click()と $(this).children(‘td’)の使い方

2017年11月17日

1.htmlコード
<table>
<tr>
<td><input type="checkbox" /></td>
<td>data11</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>data22</td>
</tr>
</table>

2.JSコード
$(document).ready(function() {
$('table tr’).click(function() {
var $tt = $(this).children('td’).children('input[type=checkbox]’);
if($tt.prop('checked’))
//処理コード1
else
//処理コード2
});
});

jQuery

Posted by arkgame