admin管理员组

文章数量:1289525

I am having table which contain some data. This table is generating using a ponent. 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 value. When I click on a label JavaScript function is triggered. Cannot use jQuery click function.

I am having table which contain some data. This table is generating using a ponent. 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 value. When I click on a label JavaScript function is triggered. Cannot use jQuery click function.

Share Improve this question edited Dec 4, 2022 at 11:33 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Sep 21, 2011 at 12:51 YasithaYasitha 1112 gold badges3 silver badges10 bronze badges 2
  • 2 Your post looks more like a list of requirements than an actual question. Did you try anything? Are you looking for help with a specific topic, and if so, which one? – Frédéric Hamidi Commented Sep 21, 2011 at 12:53
  • Why can't you use a jquery click function? – JNDPNT Commented Sep 21, 2011 at 12:53
Add a ment  | 

2 Answers 2

Reset to default 6

sample: http://jsfiddle/gCGVJ/

$('td').click(function() {
    alert($(this).closest('tr').find('input[type=checkbox]').val());
});
$('td').click(function(){

    var val = $(this).closest('tr').find('#checkbox').val();

});

本文标签: jqueryGet the closest tr value in JavaScript functionStack Overflow