2012-09-21 39 views
0

的所有TD我想通过一个表中的每个TD环路旁边$这个按钮的点击遍历下一个()表

<input type="button" class='btn'> 
<table><tr><td></td></tr>......</table> 

<input type="button" class='btn'> 
<table><tr><td></td></tr>......</table> 

<input type="button" class='btn'> 
<table><tr><td></td></tr>......</table> 

<script type="text/javascript" src="jquery.js"></script> 
<script type="text/javascript"> 
    $()ready(function(){ 
     $(".btn").click(function(){ 
      //loop through each td of next table?????? 
     }); 
    }); 
</script> 

回答

4

试试这个,

Live Demo

$(document).ready(function(){ 
     $(".btn").click(function(){ 
      //loop through each td of next table?????? 
      $(this).next().find('td').each(function(){ 
      }); 
     }); 
}); 
+0

难道你不是指'$(document).ready(function(){'? –

+0

是的,谢谢Rocket Hazmat – Adil

+0

我写在$(this).append(“*”)里面;但不工作。 –