在触发事件时更改元素的高度(javascript)
我想在单击事件时更改at元素的高度。高度设置为“自动”,但在触发事件时,我希望以不同的高度绘制图表 我的HTML看起来像:在触发事件时更改元素的高度(javascript),javascript,html,css,height,Javascript,Html,Css,Height,我想在单击事件时更改at元素的高度。高度设置为“自动”,但在触发事件时,我希望以不同的高度绘制图表 我的HTML看起来像: <table class="col-sm-12"> <tr> <td> <div class="col-sm-12" style="height: 300px;
<table class="col-sm-12">
<tr>
<td>
<div class="col-sm-12" style="height: 300px; overflow: auto !important; text-align:left" id="errorTable">
</div>
</td>
<td>
<table class="col-sm-12">
<tr> <td style="height:300px; width:100%" id="Chart"></td></tr>
<tr> <td id="errorDetails" style="height:100%; width: 100%"></td></tr>
</table>
</td>
</tr>
</table>
我试过了所有的方法,但都不管用
现在我发现,当我将ID=“chart”的高度预定义为100%时,之后我可以更改if。但这对我不起作用。我需要在开始时将图表高度的大小设置为300px,然后进行更改。但是我不工作……当你尝试将高度应用于td标签时,它不会被应用。 欲知更多详情 所以你可能需要在你的td标签里面放一个div,并在上面加上高度 HTML
这是一份工作你累了干什么?请将您的代码添加到代码段中,以便有人很快解决了您的问题。第一个问题无法解决,因为缺少单元,但第二个问题应该可以解决。当您的代码段看起来也在使用某种网格系统时,有何理由使用表和嵌套表?表格只能用于表格数据,不能用于布局
document.getElementById('Chart').setAttribute("style", "height:75");
document.getElementById('Chart').style.height = "75px";
<table class="col-sm-12">
<tr>
<td>
<div class="col-sm-12" style="height: 300px; overflow: auto !important; text-align:left" id="errorTable">
</div>
</td>
<td>
<table class="col-sm-12">
<tr>
<td >
<div id="Chart" style="height:300px; width:100%">
</div>
</td>
</tr>
<tr>
<td>
<div id="errorDetails" style="height:100%; width: 100%">
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
document.getElementById('Chart').style.height = "75px";