循环遍历next()表的所有td

时间:2012-09-21 16:51:55

标签: jquery

我想遍历一个表的每个td,这是$ this按钮的下一个点击

<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>

1 个答案:

答案 0 :(得分:4)

试试这个,

<强> Live Demo

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