javascript - $.height 在 colorbox 中返回 0

标签 javascript jquery height colorbox

我将 td 的高度设置为 auto 并希望将 tdheight 设置为colorbox 中的其他 td。这是我的 html

<tr>
    <td class="heading1" id="mhheading"><?php echo $this->translate("Medical History"); ?> </td>
    <td class="info1" style="height:auto;" id="mhinfo"><?php echo $this->patientDetail['medical_history'];?></td></tr>

我正在获取 id="mhinfo" 的高度,并希望在 id="mhheading" 中进行设置。

我的jquery代码如下

  $(document).ready(function () {
    $('#mhheading').css('height',$('#mhinfo').height());
    console.log($('#mhinfo').height());
});

我在控制台中看到它返回0。我使用了 window.loaddocument.load,但在所有情况下它都返回 0。我再次在 colorbox 中使用所有这些代码。

最佳答案

你有表格标签吗?我认为你需要添加表格标签

<table>
<tr>
    <td class="heading1" id="mhheading"><?php echo $this->translate("Medical History"); ?> </td>
    <td class="info1" style="height:auto;" id="mhinfo"><?php echo $this->patientDetail['medical_history'];?></td>
</tr>
</table>

DEMO

关于javascript - $.height 在 colorbox 中返回 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18746340/

相关文章:

javascript - Ext JS 使分页工具栏变小

javascript - Angular 5 GET 请求无响应

javascript - 如何在 IE 中将灰度和反转效果与 SVG 滤镜结合起来?

javascript - 显示加载 gif 直到 ajax 调用加载完毕(并且不与 setInterval 交互)

jQuery GET 不工作

JQuery 插件结构。带有选项的方法、方法和选项

css - 不正确的 CSS 按钮高度计算

css - 简单的CSS高度问题

德尔福: 'Property ClientHeight does Not Exist'

javascript - 无法捕获来自 ember backgroundReload 的错误