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 javascript hides elements with the mouse

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

Share

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

This article mainly introduces javascript how to hide elements with the mouse related 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 javascript how to hide elements with the mouse article will have a harvest, let's take a look at it.

Methods: 1, use the "element object .click (function () {hide element object .hide ();})" statement to set the mouse click to hide the element; 2, use the "element object .dblclick (function () {hide element object .hide ();})" to set the mouse double-click to hide the element.

The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.

How does javascript hide elements with the mouse

In JavaScript, mouse events are the most commonly used event types in Web development. The details of mouse event types are shown in the following table:

The hide () method is used to hide the selected element if it is already displayed.

The syntax is:

$(selector) .hide (speed,callback)

Speed

Optional. Specifies the speed at which the element is hidden from the visible. The default is "0".

Possible values:

Milliseconds (e.g. 1500)

"slow"

"normal"

"fast"

In the case of setting the speed, the element gradually changes its height, width, outer margin, inner margin, and transparency as it is visible and hidden.

Callback

Optional. The function to be executed after the hide function has been executed.

Examples are as follows:

$(document) .ready (function () {$(".btn") .click (function () {$(".btn") .hide ();}); .btn {width:100px; height:100px; background:pink;} this is an element to be hidden

Output result:

Example 2:

$(document) .ready (function () {$(".btn") .dblclick (function () {$(".btn"). Hide ();}); .btn {width:100px; height:100px; background:pink;} this is an element to be hidden

Output result:

You need to double-click the hidden element.

This is the end of the article on "how javascript hides elements with the mouse". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to hide elements with the mouse in javascript". If you want to learn more, you are welcome to follow the industry information channel.

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