Get the closest tr value in JavaScript function
I am having table which contain some data. This table is generating using a component. All td's has the same class name. Each row begins with a check-box with a specific value to that row. When click on a td on that row I want to get check-box v开发者_运维知识库alue. When I click on a label JavaScript function is triggered. Cannot use jQuery click function.
sample: http://jsfiddle.net/gCGVJ/
$('td').click(function() {
alert($(this).closest('tr').find('input[type=checkbox]').val());
});
$('td').click(function(){
var val = $(this).closest('tr').find('#checkbox').val();
});
精彩评论