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 click on the display element and click on the hidden element again in jquery

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "jquery how to click on the display element and click on the hidden element again". The content in the article is simple and clear, and it is easy to learn and understand. below, please follow the editor's train of thought slowly and deeply, together to study and learn "jquery how to click on the display element and click on the hidden element again"!

Methods: 1, use the click () method to bind the click event to the button and specify the handler function; 2, in the function with if statement, show () and hide () to achieve, the syntax "if (element object .is (': hidden')) {element object .show ();} else {element object .hide ();}".

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

How to click on the display element and click on the hidden element again in jquery

In jquery, you can click the button to show and click to hide again through the show () method and the hide () method, and the hide () method hides the selected element if it is already displayed. The syntax is:

$(selector) .hide (speed,callback)

The show () method displays selected elements if they are hidden. The syntax is:

$(selector) .show (speed,callback)

Let's take a look at how to achieve county-level display and click hide again through an example, as shown below:

Div {width:100px;height:100px;background: red;} Show and hide $(function () {('# anniu') .click (function () {/ / Click the button if ($('# test'). Is (': hidden')) {/ / if currently hidden $('# test'). Show (); / / Click to show} else {/ / otherwise $('# test'). Hide (); / / Click to hide}})

Output result:

Thank you for your reading, the above is the content of "jquery how to click on the display element and click on the hidden element again". After the study of this article, I believe you have a deeper understanding of how to click on the display element and click on the hidden element again in jquery, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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