【发布时间】:2010-12-28 23:29:38
【问题描述】:
我有一个通过 jquery/ajax 调用 php 页面的脚本。结果如下所示:
<table class="table" cellspacing="0" width="100%">
<thead>
<tr>
<th scope="col">Title1</th>
<th scope="col">Title2</th>
<th scope="col">Title3</th>
</tr>
</thead>
<tbody><?php echo $wait_list; ?></tbody>
</table>
<div>
<div id="statcount">Rows: <?php echo $row_count; ?></div>
</div>
当通过 jquery/ajax 调用调用它时,它会显示表信息,最后显示 div 信息。但是我不希望底部 div 显示,我实际上希望它从数据中删除,我只是把它放在那里,所以我可以获取计数并将它放在与调用此文件的脚本不同的 div 中,所以我不必制作 2单独的 jquery/ajax 调用。因此,当 jquery/ajax 调用成功时,它会运行:
function updateList(data){
$('#rowcount').html($('#statcount',data).html());
$('#statcount',data).remove();
$("#waitlist").html(data);
}
如您所见,我使用该 div 填充页面上的单独区域。但是一旦完成,我不希望 php 页面中的 div 显示在#waitlist 中。如您在上面看到的,我尝试了 remove() 函数,但这不起作用。有什么建议吗?
【问题讨论】:
-
一个非常糟糕的方法:用 CSS 隐藏有问题的
div-<div style="display:none"><div id="statcount">Rows: <?php echo $row_count; ?></div></div> -
@thirtydot:实际上我试过了,但它在最后的表格行中留下了一个间距。
-
@thirtydot:你知道吗,这确实有效。我只是移动了 div 而不是表格标签,然后手动将其设置为 display:none。这很糟糕,但如果没有其他选择,那么我现在就使用它。