Home > Web Front-end > JS Tutorial > Introduction to the method of hiding controls in js and the display attribute_javascript skills

Introduction to the method of hiding controls in js and the display attribute_javascript skills

WBOY
Release: 2016-05-16 17:30:08
Original
1495 people have browsed it

There are two ways to hide controls using JavaScript, one is by setting the "display" and "visibility" attributes of the control's style. The control is visible when style.display="block" or style.visibility="visible", and is invisible when style.display="none" or style.visibility="hidden". The difference is that "display" not only hides the control, but also the hidden control no longer occupies the position occupied when displayed, while the control hidden by "visibility" only sets the control to be invisible, and the control still occupies its original position.

Copy code The code is as follows:

function displayHideUI()
{
var ui = document.getElementById("bbs");
ui.style.display="none";
}
function displayShowUI()
{
var ui = document.getElementById(" bbs");
ui.style.display=" ";//It will work if the display is empty, and the block will cause the following space to wrap
}
function visibilityHideUI()
{
var ui = document.getElementById("bbs");
ui.style.visibility="hidden";
}
function visibilityShowUI()
{
var ui = document. getElementById("bbs");
ui.style.visibility="visible";
}


display: Value description None's element will not be displayed.
block This element will be displayed as a block-level element, with line breaks before and after this element.
inline is the default. This element will be displayed as an inline element with no line breaks before or after the element.
inline-block Inline block element. (New value in CSS2.1)
list-item This element will be displayed as a list.
run-in This element will appear as a block-level element or an inline element, depending on the context.
compact CSS There is a value compact in CSS, but it has been removed from CSS2.1 due to lack of widespread support.
marker There are value markers in CSS, but they have been removed from CSS2.1 due to lack of widespread support.
table This element will be displayed as a block-level table (similar to ), with line breaks before and after the table.
inline-table This element will be displayed as an inline table (similar to
), with no line breaks before and after the table.
table-row-group This element will be displayed as a group of one or more rows (similar to ).
table-header-group This element will be displayed as a group of one or more rows (similar to ).
table-footer-group This element will be displayed as a group of one or more rows (similar to ).
table-row This element will be displayed as a table row (similar to ).
table-column-group This element will be displayed as a group of one or more columns (similar to ).
table-column This element will be displayed as a cell column (similar to )
table-cell This element will be displayed as a table cell (similar to
and )
table-caption This element will be displayed as a table title (similar to
)
inherit specifies that the value of the display attribute should be inherited from the parent element.
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