Prevent style inheritance of 'display' when setting style using Javascript

后端 未结 2 595
天命终不由人
天命终不由人 2020-12-22 05:06

I would like to toggle the visibility of a larger portion of HTML using Javascript, which also contains display: properties.

Problem is th

2条回答
  •  不知归路
    2020-12-22 05:57

    I should have added, that I am using FF11. Maybe I discovered a bug, shortcoming or 'legacy', but the trick is the following:

    1. The class 'zapfenintermeddivisionrow' (initially containing display:none) is assigned to a TR, a table row.
    2. There is the display:table-row property http://www.w3schools.com/cssref/pr_class_display.asp, never heard of that before.
    3. By toggling items[i].style.display between 'none' and 'table-row' it's now doing what I thought it should do.

    As correctly stated by @powerbuoy, the style attribute is NOT automatically propagated to childs. In the case where the element is a TR, FF behaves oddly though, if eg. block is assigned.

提交回复
热议问题