Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the concealment of adjacent elements of click elements by jquery

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

The main content of this article is to explain "how to click on jquery to hide adjacent elements". Friends who are interested may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "jquery how to click on the elements of adjacent elements hidden" bar!

Method: 1, use click () to bind the click event to the element, and set the handler function; 2, in the handler function, use next () and prev () function to get adjacent elements, and use hide () to hide the obtained elements, the syntax is "element .next (). Hide (); element .prev (). Hide ()".

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

Jquery implements click elements, and their adjacent elements are hidden

Implementation method:

Use the click () function to bind the click event to the specified element and set the handler

In the processing function, use the next () and prev () functions to get adjacent elements, and use the hide () function to hide the acquired elements

Next (): used to get the next peer element.

Prev (): used to get the previous peer element.

Implementation code:

.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"}) $("li.start") .click (function () {$("li.start") .next () .hide (); $("li.start") .prev () .hide ();}) }) Ul (parent node) li li (adjacent element with class name "star") li element with class name "star" Li (neighboring elements with class name "star") li

Click on the li element with the class name "star" to hide its two adjacent elements

At this point, I believe you have a deeper understanding of "jquery how to achieve click element adjacent element hiding", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report