htmlコード:
<tr id="myname">
<td><input class="count" type="text" value="1"></td>
</tr>
jqueryコード:
$('input.count').keyup(function(e){
var test = $(this).parent().parent().attr('id');
alert(test);
});
キーアップ入力時に、tr idを取得します!
htmlコード:
<tr id="myname">
<td><input class="count" type="text" value="1"></td>
</tr>
jqueryコード:
$('input.count').keyup(function(e){
var test = $(this).parent().parent().attr('id');
alert(test);
});
キーアップ入力時に、tr idを取得します!
jQueryでclosest()メソッドを 試すことができます。
$('input.count').keyup(function(e){
var test = $(this).closest('tr').attr('id');
alert(test);
});
実例は次のとおりです:DEMO
<table></table>違いは、タグを提供していないことです。