<input type="button" onclick="getTable()">
...
...
<table>
  ...
</table>
<script>
  function getTable()
  {
     ..这里取得对像后面的第一个table谢谢
  }
</script>

解决方案 »

  1.   

    <html>
    <head> 
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script>
    function getTable(obj){
        alert($(obj).next("table").attr("id"));
    }
    </script>
    </head>
    <body><input type="button" onclick="getTable(this)"> 
    ... 
    ... 
    <table id=aa> 
      ... 
    </table> 
    </body>
    </html>
      

  2.   

    <html>
    <head> 
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script>
    function getTable(obj){
        var i=$("input,table").index(obj);
        alert($("input,table").get(i+1).id);
        
    }
    </script>
    </head>
    <body><input type="text" id=s1 > <input type="button" id=s2 onclick="getTable(this)"> 
    ... 
    ... 
    <table id=aa> 
      ... 
    </table> 
    <div id=bb>ddd</div>
    </body>
    </html>
      

  3.   

    <html>
    <head> 
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script>
    function getTable(obj){
        var i=$("input[onclick='getTable(this)'],table").index(obj);
        alert($("input[onclick='getTable(this)'],table").get(i+1).id);
        
    }
    </script>
    </head>
    <body>
    <input type="text" > <input type="button" onclick="getTable(this)"> 
    <input type="text" >
    ... 
    ... 
    <table id=aa> 
      ... 
    </table> 
    <div id=bb>ddd</div>
    </body>
    </html>