2012-03-06 58 views
0

我使用jQuery來顯示錶TR爲以下TR 0可見,並且有一個鏈接: 行1在行0下不可見,當用戶單擊行0時,鏈接行1變爲可見。顯示使用jQuery

但是當我點擊這個鏈接第1行出現,但在第0行TD。

這裏是我的Jquery:

function expand_ClickEvent(rowData){ 

       //get the TR that you want to show/hide 
       var _TR = $("#tr_0"); 
       var TR = $("#tr_1"); 
       //check its class 
       if (TR.hasClass('hide')){ 
        TR.removeClass('hide'); //remove the hide class 
        TR.addClass('show'); //change it to the show class 
        TR.insertAfter(_TR); 
        //TR.show();    //show the TR (you can use any jquery animation) 

       } else { 
        TR.removeClass('show'); //remove the show class 
        TR.addClass('hide'); //change it to the hide class 
        TR.hide();    //hide the TR (you can use any jquery animation) 

       } 
      } 
+0

您的問題是什麼? – DarkAjax 2012-03-06 14:46:13

+0

下排0 TD,而不是TR – 2012-03-06 14:50:08

回答

0

如果您html已經包含thesecond tr,你不應該再插入。 並且還使用toggle函數。
您的代碼將只是一行:

$("#tr_1").toggle(); 
+0

不工作,我不明白爲什麼: if (TR.hasClass('hide')){ \t \t \t TR.removeClass('hide'); //remove the hide class \t \t \t TR.addClass('show'); //change it to the show class \t \t \t //TR.show(); //show the TR (you can use any jquery animation) \t \t \t TR.toggle(); \t \t \t \t \t \t \t } 2012-03-06 15:18:51

+0

@謝里夫??你什麼意思?你能用相應的'html'代碼更新你的問題嗎? – jb10210 2012-03-07 14:25:34