单击jquery列值

我有一个包含5列的表,当我点击该行的第一列时,我需要使用jquery获取所有列的行值?

谢谢

如果你想在数组中得到答案:

$('table#mytable td:first-child').click( function(){ var resultArray = $(this).closest('tr').find('td').map( function(){ return $(this).text(); }); // Do something with resultArray // resultArray is a jQuery object // resultArray.get() is a plain array. get() can be chained above. }); 
 $("td:first-child").click(function(){ $(this).closest('tr').find("td").each(function(){ alert(this.innerHTML); }); }); 
 $("td").click(function(){ $(this).parent().find("td").each(function(){ alert(this + " is one entry of your current row"); }); }); 

取决于表中的实际内容。

 var mystuff = $("td").click().parent('tr').children('td').text(); var mystuff = $("td").click().parent('tr').children('td').innerHtml(); 

访问它们:

 mystuff.each(function() { //do stuff }; mystuff.eq(2) // do stuff with second one