gpt4 book ai didi

jquery - 通过 jQuery 加载到 div 时,表格看起来不正确

转载 作者:行者123 更新时间:2023-12-01 06:02:50 25 4
gpt4 key购买 nike

cladtemplate.php 输出一个表格(我正在创建专门为 craigslist 广告生成的输出,该广告不允许使用 div 标签),但是当表格加载到跨度中时,所有行都会高约 5 像素。当我将内容加载到 DIV 中时,也会发生同样的情况,但如果我使用 iFrame,结果看起来没问题。

关于为什么会发生这种情况有什么想法吗?

<span style="width:850px; height:100px" id="prev"> </span>
<script src="jquery.js"></script>
<script>
var area = 100;
$(document).ready(function() {
setInterval(timer, 4000);
area += 50;
})
function timer(){
updatePreview();
$('#prev').load(function () {
$(this).height($(this).contents().height());
$(this).width($(this).contents().width());
});
}
function updatePreview()
{
$.ajax({

type: "GET",
url: 'cladtemplate.php',
//data: "name=' + name + '&area=' + area,
datatype: 'html',
success: function(data) {
$('#prev').html(data);
}

});

}
</script>

编辑:某些表格单元格包含与单元格尺寸相同的图片。不知道这是否相关。我可以发布 cladtemplate.php 中的代码,但它有很多行。

第二次编辑:这是一些 html:

<table id="Table_01" width="800" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="33" height="0" nowrap="nowrap"></td>
<td width="35" height="0" nowrap="nowrap"></td>
<td width="51" height="0" nowrap="nowrap"></td>
<td width="80" height="0" nowrap="nowrap"></td>
<td width="48" height="0" nowrap="nowrap"></td>
<td width="56" height="0" nowrap="nowrap"></td>
<td width="48" height="0" nowrap="nowrap"></td>
<td width="32" height="0" nowrap="nowrap"></td>
<td width="17" height="0" nowrap="nowrap"></td>
<td width="11" height="0" nowrap="nowrap"></td>
<td width="279" height="0" nowrap="nowrap"></td>
<td width="42" height="0" nowrap="nowrap"></td>
<td width="18" height="0" nowrap="nowrap"></td>
<td width="11" height="0" nowrap="nowrap"></td>
<td width="39" height="0" nowrap="nowrap"></td>
<td width="0" height="0"></td>
</tr>
<tr>
<td width="800" height="50" colspan="15">
<img id="cglist_ad_template_01" src="images/cglist-ad-template_01.jpg" width="800" height="50" alt="" /></td>
<td width="0" height="50" nowrap="nowrap"></td>
</tr>
<tr>
<td width="199" height="128" colspan="4" rowspan="4">
<img id="cglist_ad_template_02" src="images/cglist-ad-template_02.jpg" width="199" height="128" alt="" /></td>
<td width="533" height="58" colspan="8" bgcolor="ececec"><center><font size="6">
_END;
echo "$" . $price . ", " . $area;
echo <<<_END
</font></center></td>
<td width="68" height="104" colspan="3" rowspan="2">
<img id="cglist_ad_template_04" src="images/cglist-ad-template_04.jpg" width="68" height="104" alt="" /></td>
<td width="0" height="58" nowrap="nowrap"></td>
</tr>
<tr>
<td width="533" height="46" colspan="8">
<img id="cglist_ad_template_05" src="images/cglist-ad-template_05.jpg" width="533" height="46" alt="" /></td>
<td width="0" height="46" nowrap="nowrap"></td>
</tr>
<tr>
<td width="201" height="24" colspan="5" rowspan="2">
<img id="cglist_ad_template_06" src="images/cglist-ad-template_06.jpg" width="201" height="24" alt="" /></td>
<td width="350" height="18" colspan="4" bgcolor="a1d528"></td>
<td width="50" height="579" colspan="2" rowspan="18">
<img id="cglist_ad_template_08" src="images/cglist-ad-template_08.jpg" width="50" height="579" alt="" /></td>
<td width="0" height="18" nowrap="nowrap"></td>
</tr>
<tr>
<td width="350" height="250" colspan="4" rowspan="10">
_END;
echo "<img id=\"cglist_ad_template_12\" src=\"bigollizard.png\" width=\"350\" height=\"250\" alt=\"\" />";
echo <<<_END
</td>
<td width="0" height="6" nowrap="nowrap"></td>
</tr>
<tr>
<td width="119" height="54" colspan="3" rowspan="2">
<img id="cglist_ad_template_10" src="images/cglist-ad-template_10.jpg" width="119" height="54" alt="" /></td>
<td width="184" height="43" colspan="3"bgcolor="ececec"><center><font size="4">INFORMATION</font></center></td>
<td width="97" height="54" colspan="3" rowspan="2">
<img id="cglist_ad_template_12" src="images/cglist-ad-template_12.jpg" width="97" height="54" alt="" /></td>
<td width="0" height="43" nowrap="nowrap"></td>
</tr>
<tr>
<td width="184" height="11" colspan="3" bgcolor="ececec"></td>
<td width="0" height="11" nowrap="nowrap"></td>
</tr>
<tr>
<td width="68" height="501" colspan="2" rowspan="14">
<img id="cglist_ad_template_14" src="images/cglist-ad-template_14.jpg" width="68" height="501" alt="" /></td>
<td width="179" height="21" colspan="3" bgcolor="ececec">Bedrooms:</td>
<td width="104" height="21" colspan="2" bgcolor="ececec">

...等等。

编辑第三个!这是生成的两个表格顶部的屏幕截图:顶部位于 iframe 中并且底部位于跨度内

http://s14.postimage.org/651uhnnq9/Untitled.png

最佳答案

您只能绑定(bind)到具有 URL 的元素(例如图像或脚本元素)的 load 事件。

所以:

    $('#prev').load(function () {
$(this).height($(this).contents().height());
$(this).width($(this).contents().width());
});

可能不会触发,因为 #prev 是一个容器(我假设是一个 DIV)。我不确定这是否是您问题的根源,但需要注意。

查看 cladtemplate.php 的 HTML 输出会很有帮助。

关于jquery - 通过 jQuery 加载到 div 时,表格看起来不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9524670/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com