2012-09-21 38 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(「*」)裏面;但不工作。 –