1

我的页面中有一个 div (id = "first") 和一个表单 ("search-form")
div 显示了我在数据库中的表的所有记录。在表单中,用户可以通过表单中的文本来限制结果。我想用基本的 div 替换新的 div。


看法:

 <div class="datagrid" id="first">
    <table>
      <tr>
        <th>id</th>
        <th>num</th>
      </tr>
        <?php 
            foreach ($this ->paginator as $key =>$value)
            {    
                echo '<tr>
                        <td>'.$value->id.'</td>
                        <td>'.$value->num.'</td>
                 </tr>';                                                        
            }
        ?>
  </table>
 </div>
 </div>
<div class = "pagination">
    <?php 
        echo $this->paginationControl($this->paginator,'Sliding','pagination.phtml' );
    ?>
</div>
<div class= "search-form">
        <?php 
        echo $this->form;
        echo $this->errorMessage; 
        ?>
</div>
<div class="datagrid" id = "last">

    <table>
         <tr>
            <th>id</th>
            <th>num</th>
          </tr>
        <?php 
                    for ($i=0 ; $i<$this->rowCount; ++$i)
                    {       
                            print  '<tr><td>'. ($this->rowArray[$i]['id']).'</td>';
                            print  '<td>'. ($this->rowArray[$i]['num']).'</td>';
                    }?>
    </table>
</div>
4

1 回答 1

0
$('#first').html($('#last').html());

但是您必须在加载文档时执行此操作,以便在

$( document ).ready(function()
{
  $('#first').html($('#last').html());
});
于 2015-01-31T18:18:32.127 回答