2012-01-17 63 views
1

有谁知道如何使表下滚动,以及能够保持表标题固定,所以它不会向下滚动表?如何使表可滚动固定标题

下面是HTML和jQuery

<table id="qandatbl"> 
     <thead> 
     <tr> 
      <th class="answer">Answer</th> 

     </tr> 
     </thead> 
     </table> 


    function insertQuestion(form) { 


     var $tbody = $("<tbody></tbody>"); 
     var $tr = $("<tr class='optionAndAnswer'></tr>"); 
     var $answer = $("<table class='answer'></table>"); 

    var $this, i=0, $row, $cell; 
    $('#optionAndAnswer .answers').each(function() { 
     $this = $(this); 
     if(i%7 == 0) { 
      $row = $("<tr/>").appendTo($answer); 
      $cell = $("<td/>").appendTo($row); 
     } 

     var $newBtn = $("<input class='answerBtnsRow answers' type='button' style='display:%s;' onclick='btnclick(this);' />".replace('%s',$this.is(':visible')?'inline-block':'none')).attr('name', $this.attr('name')).attr('value', $this.val()).attr('class', $this.attr('class')); 


     $newBtn.appendTo($cell); 

     i++; 
    }); 

     $tbody.append($tr); 
     $tr.append($answer); 
     $('#qandatbl').append($tbody); 

    } 
+0

http://stackoverflow.com/questions/1965976/fixed-thead-in-table – ScottE 2012-01-17 01:14:56

回答