...
<input class = "button"  id  = "one"   value = "展开" />
<table>
....
....
</table>
 <script type = "text/javascript">
        $(".button").click(function () {
            var $id = $(this).attr("id");
            var table = document.getElementById("one"); //换成 document.getElementById(); 报错提示 不支持此属性或方法,我就是想获得 $id 的 id ,然后获得 class 为button后面的 table 让table 展开, 因为有不少相同的table 要展开         
            $(table).show(1000);           
        });
    </script>
 

解决方案 »

  1.   

    $(".button").click(function () {
                var $id = $(this).attr("id");      
                $('#'+$id).show(1000);           
            });
    直接这么写就Ok吧~·
      

  2.   

    补充一下 table 是设置成  <table style=" display:none"> 的 
      

  3.   

    <table>
    ....
    ....
    </table>
    我看你这table上没有id啊
      

  4.   

    <input class = "button"  block = "one"   value = "展开" />
    <table id="one" style=" display:none"> 
    (".button").click(function () {
      var $id = $(this).attr("block");   
      $('#'+$id).show(1000);   
      });
      

  5.   

    你所有的table是什么样子???
      

  6.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <script type="text/javascript" src="http://www.wanmei.com/public/js/jq_132.js"></script>
    </head><body>
    <input class = "button" type="button" block = "one" value = "展开" />
    <table id="one" style=" display:none">  
    <tr>
    <td>11111111</td>
    </tr>
    </table>
    <script type="text/javascript">
    $(".button").click(function () {
      var $id = $(this).attr("block"); 
      $('#'+$id).show(1000);   
      });
    </script>
    </body>
    </html>
    看我这例子
      

  7.   

    $(document).ready( function() {
        $(".button").click( function() {
            $(this).next("table:eq(0)").show(1000);
        });
    });
      

  8.   

    5楼已经发现了。
    楼主自己好好看看代码,怎么能有这样的错误。你到底在操作谁?按你开始写的那个代码,整个都乱了。还有一个问题上面没挑出来,就是“展开”按钮。不是class=button就可以了,必须要有 type=button才行。
    <input type= "button" class = "button" value = "展开" />另外,看楼主下面说的报错和自己的希望,这应该是有多对BUTTON和TABLE存在,想让每个BUTTON控制随后的TABLE的隐现——问问题最好一开始就把所有情况说清楚,不要只冰山一角。这还不如挤牙膏,挤牙膏是每挤出一点都是有用的,而你这样不把情况全说明白,可能每说一点就会导致解决方法完全不适用。这个问题到底是怎样的,楼主再重新全面说一下吧。在此前,你可以好好看看JQ的EACH方法和相关的例程。建议先阅读理解几十个JQ的示例再自己写。
      

  9.   

    呵呵  type="button" 是写有,我手工写的上面的代码
      

  10.   

    谢谢 楼上兄弟们  自己 一句代码搞定了
     $(".button").click(function () {
                $(this).next().show(1000);
            });功能是 前面是个button ,后面紧跟着一个table ,table初始状态是隐藏的,点击某个button,相应后面跟着的table 展开内容, nnd  不小心弄掉了个$,写成(".button").click(function () { 当然总报错了