How jquery hides parent elements
This article mainly introduces the jquery how to hide the parent elements of the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this jquery how to hide the parent elements of the article will have a harvest, let's take a look at it.
Jquery hides the parent element of the method: 1, use parent () to get the specified element's parent element, syntax "$(" specified element "). Parent ()"; 2, use hide (), fadeTo (), slideUp () and other functions to hide the acquired elements, syntax "parent element object .hide ()".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
How does jquery hide parent elements
In jquery, to hide the parent element of a specified element, you first need to get the parent element, and then hide it.
You can use the parent () method to get the parent element, which returns the direct parent element of the selected element.
Once you get the parent element, you can use hidden elements such as hide (), fadeOut (), fadeTo (), slideUp (), etc.
The hide () method hides the selected element (by adding a display:none style to the element).
The fadeOut () method gradually changes the opacity of the selected element from visible hiding (fading effect).
The slideUp () method hides the selected element in a sliding manner.
The fadeTo () method gradually changes the opacity of the selected element to the specified value (fade effect); you just need to set the final opacity to 0.
Example: hide the parent element using parent () and hide ()
.siblings * {display: block; border: 2px solid lightgrey; color: lightgrey; padding: 5px; margin: 15px } $(document) .ready (function () {$("li.start") .css ({"color": "red") "border": "2px solid red"}) $("button") .click (function () {$("li.start"). Parent (). Hide ();}) Div container ul (parent node) li (last sibling node of class name "star") li (last sibling node of class name "star") Li element li with class name "star" (next sibling node with class name "star") li (next sibling node with class name "star")
Hide the parent element of the class name "star"-ul
Hide parent element
Description: because the style is inherited, hiding hides the child elements under the parent element together.
This is the end of the article on "how jquery hides parent elements". Thank you for reading! I believe you all have a certain understanding of "how jquery hides parent elements". If you want to learn more, you are welcome to follow the industry information channel.