Reputation: 1440
Jquery Code:
$("[id$=mytable] tr").click(function() {
alert($(this).html());
});
Html:
<table id="mytable">
<tr>
<td class="locked">1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td class="locked">a</td>
<td>b</td>
<td>c</td>
</tr>
</table>
ı need only "td class='locked'" click return this
click: <td class="locked">1</td>
output:
<tr>
<td class="locked">1</td>
<td>2</td>
<td>3</td>
</tr>
Upvotes: 0
Views: 62
Reputation: 382616
$(function(){
$('td.locked').click(function(){
var html = $(this).parent().html();
alert('<tr>' + html + '</tr>');
});
});
Upvotes: 2
Reputation: 3324
$('table#mytable tr td.locked').click(function() {
alert($(this).parent().html());
});
Upvotes: 1
Reputation: 70314
I originally had a solution much like the others here, that is, to bind the callback to the td.locked
. I guess you really want to bind it to the tr
and only output the td.locked
, so here is my version:
$("#mytable tr").click(function() {
alert($(this).find("td.locked").html());
});
Upvotes: 0