When javascript controls the display mode of table tr display block, it is only valid for the first cell.

Source: Internet
Author: User

When javascript controls the display mode of table tr display block, it is only valid for the first cell.

There is a simple table:


 

<Table> <tr> <th> Number </th> <th> type </th> <th> details </th> <th> creation time </th> <th> modification time </th> <th> operation </th> </tr> <td> 5 </th> <td> TECH </th> <td> test content </th> <td> 2014 −01 −10 16:56:31 </th> <td> −−</th> <td> modify and delete </th> </tr> <tr id = "id_dync" style = "display: none "> <td colspan = 6> <div id = xxxx> test content </div> </td> </tr> </table>

You want to use javascript to control the hidden status of tr in the third line:

var tr_modifing = document.getElementById( "id_dync" );tr_modifing.style.display = "block";

After you set style. display to block, it will only be valid for the first cell td:


The reason is to set tr. style. after the display = "block", the tr is not a normal [Table] [row], but a common block like a common div, so the following

<td colspan=6 >

It will also become invalid. The correct method is

var tr_modifing = document.getElementById( "id_dync" );tr_modifing.style.display = "";

The display mode of tr is set to null. This attribute dispaly is not followed by anything. It is strange that it is compatible with Firefox and IE.



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.