You cannot use block to hide table rows in Firefox or chrome.

Source: Internet
Author: User
You cannot use block to hide table rows in Firefox.

The following code can be executed normally in IE, but it is a bit abnormal in Firefox:
<Script language = "JavaScript">
Function testblack (tagname ){
VaR OBJ = Document. getelementbyid (tagname );
If (obj. style. Display = "Block "){
OBJ. style. Display = "NONE ";
} Else {
OBJ. style. Display = "Block ";
}
}
</SCRIPT>
<Table width = "760" border = "0" cellspacing = "0" cellpadding = "0">
<Tr onclick = "testblack ('divb ');">
<TD width = "760" Height = "20" bgcolor = "#00 CCFF"> click me! </TD>
</Tr>
<Tr id = "divb" style = "display: block;">
<TD width = "760" Height = "60" bgcolor = "# 9966ff"> </TD>
</Tr>
</Table>

Some netizens said that CSS may be unable to process tables. I personally think it is not because the above Code can be executed normally on IE; some netizens also said that the execution of "display: none;" was not recycled after "display: block;" opened page space was executed in Firefox, and "display: block;" was executed next time; "The display space will be re-created on the page, which is also untenable. The following code is normal for Firefox execution when used on Div:
<Script language = "JavaScript">
Function testblack (tagname ){
VaR OBJ = Document. getelementbyid (tagname );
If (obj. style. Display = "Block "){
OBJ. style. Display = "NONE ";
} Else {
OBJ. style. Display = "Block ";
}
}
</SCRIPT>
<Div style = "width: 760px; Height: 20px;" onclick = "testblack ('diva ');"> click me! </Div>
<Div id = "Diva" style = "width: 760px; Height: 60px; display: block;"> </div>

So far, we have not found a credible reason, but it does not mean that the table rows cannot be dynamically displayed/hidden in Firefox. display = ""; 'replaces 'style. display = "Block:
<Script language = "JavaScript">
Function testblack (tagname ){
VaR OBJ = Document. getelementbyid (tagname );
If (obj. style. Display = ""){
OBJ. style. Display = "NONE ";
} Else {
OBJ. style. Display = "";
}
}
</SCRIPT>
<Table width = "760" border = "0" cellspacing = "0" cellpadding = "0">
<Tr onclick = "testblack ('divc ');">
<TD width = "760" Height = "20" bgcolor = "#00 CCFF"> click me! </TD>
</Tr>
<Tr id = "divc">
<TD width = "760" Height = "60" bgcolor = "# 9966ff"> </TD>
</Tr>
</Table>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.