How to use jquery to hide elements
This article introduces the knowledge of "how to realize the hidden elements of jquery". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Implementation: 1, use css () to add visibility style to the element, set invisible, syntax "element object .css ('visibility','hidden');"; 2, use css () to set the transparency of the element to 0, syntax "element object .css (' opacity',0)".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
There are two ways to implement occupancy hiding elements:
Add visibility: hidden; style to the element
Add opacity: 0 style to the element
In jquery, you can use the css () method to achieve the above effect:
1. Use css () to add visibility style to the element, and the setting is not visible.
$(document) .ready (function () {$("button") .click (function () {$(".blank") .css ("visibility", "hidden");});}) Normal display element hidden element normal display element
Occupies a position to hide elements
Description:
The visibility attribute specifies whether the element is visible.
This attribute specifies whether to display an element box generated by an element. This means that the element still occupies its original space, but it can be completely invisible. The value collapse is used in the table to delete columns or rows from the table layout.
Method 2: use css () to set the transparency of the element to 0
$(document) .ready (function () {$("button") .click (function () {$(".opacity") .css ('opacity',0);});}) Normal display element hidden element normal display element
Occupies a position to hide elements
Description:
The opacity attribute means to set the transparency of an element. It is not designed to change the element's bounding box (bounding box).
This means that setting opacity to 0 can only visually hide elements. The element itself still occupies its own place and plays a role in the layout of the page. This is similar to visibility: hidden above.
This is the end of the content of "how jquery achieves location-occupying hidden elements". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!