Home > Web Front-end > JS Tutorial > firefox TBODY solution to misalignment when displaying and hiding with js_javascript skills

firefox TBODY solution to misalignment when displaying and hiding with js_javascript skills

WBOY
Release: 2016-05-16 18:57:47
Original
1428 people have browsed it

Look at the following example:


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

When it is displayed in firefox , the "first line" is displayed on the last line.
So after processing the lines that need to be displayed, I wrote another function to first record the lines that need to be displayed, then set the style.display of all lines to "none", and finally display the lines that need to be displayed in sequence. come out. In this way, the display results of IE and Firefox will be the same.
Later, I still felt that this method was stupid, so I studied it again and found that as long as I added style="display:block" to the second and third lines, the display would be normal. See the code below:

[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute
]

It can be seen that firefox has Whether style="display:block" is set is treated differently, and IE has made appropriate compatibility processing. The conclusion and lesson is: try to use standard practices and don’t expect browser compatibility. I often forget this after using IE too much. Note: If you don’t use tbody, you don’t have this problem. But tbody can play the role of grouping rows, which is useful when you need to show or hide multiple rows at a time.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template