假设我有这样的代码:
<table>
<tr style="background-color: red"><td><pre>This is line one</pre></td></tr>
<tr style="background-color: red"><td><pre></pre></td></tr>
<tr style="background-color: red"><td><pre>This is line three</pre></td></tr>
<tr style="background-color: red"><td><pre>This is line four</pre></td></tr>
</table>
我希望第二行与其他行的高度相同。有办法做到这一点吗?
最佳答案
为其设置样式。
tr{
height: 20px;
}
如果你想使用 javascript (jQuery) 那么像这样。
var maxHeight =0;
$("tr").each(function(){
if($(this).height()>maxHeight){
maxHeight = $(this).height();
}
});
$("tr").css({height: maxHeight+'px'});
这是一个 jsFiddle:http://jsfiddle.net/Xtyqr/
关于javascript - 我可以强制尝试不崩溃吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4839723/