Get the App
SLTechnology News&Howtos  ›  Development  › 

How javascript hides elements with the mouse

Shulou Source: shulou.com Published: 2022-06-01 17:32:47 10月26日 Update

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.

Tags: Element mouse object event knowledge content function method example article type result this is speed output value width commonly used case easy to operate Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Huawei Shulou Information Xiaomi vpn