更改表行显示属性 [英] Change table row display property
问题描述
我有一个html页面,其中包含一个隐藏行的表格:
I have an html page with a table that contains a hidden row:
<table>
<tr id="hiddenTr" style="display:none">
...
</tr>
</table>
我需要使用jquery在客户端显示它。我试过这个
I need to make it visible at client side using jquery. I tried this
$('#hiddenTr').show();
此
$('#hiddenTr').css('display', 'table-row');
两种实现都不适用于我。更重要的是,第二个不是crossbrowser。
Both implementations don't work for me. Furthemore the second one is not crossbrowser.
UPD。对不起,伙计们。这是我的错:我错误输入了tr元素id。奇怪的是$('hiddenTr')没有返回null ...
UPD. Sorry, guys. That was my fault: I mistyped tr element id. That's strange $('hiddenTr') didn't return null...
推荐答案
我总是将style.display属性设置为(空字符串)显示隐藏的表格行:
I always set the style.display property to "" (empty string) to show a hidden table row:
var row = document.getElementById('row_id');
row.style.display = ""; // shows the row
要再次隐藏它:
row.style.display = "none"; // hides the row
,这将是:
$("#row_id").css("display", ""); // show the row
或
$("#row_id").css("display", "none"); // hides the row
IE似乎不喜欢显示的'table-row'值。并且'阻止'不正确,有时它似乎搞砸了其他浏览器中的显示。
IE doesn't seem to like the 'table-row' value for display. And 'block' is not correct, and it seems to screw up the display in other browsers sometimes.
这篇关于更改表行显示属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!