Get the App
SLTechnology News&Howtos  ›  Development  › 

How jQuery makes HTML elements slide up and down

Shulou Source: shulou.com Published: 2022-06-01 13:13:19 10月03日 Update

This article will explain in detail how jQuery makes HTML elements slide up and down. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

JQuery sliding method

With jQuery, you can create a sliding effect on an element. JQuery has the following sliding methods:

SlideDown () slideUp () slideToggle ()

JQuery slideDown () method

The jQuery slideDown () method is used to slide the element down. Syntax:

$(selector) .slideDown (speed,callback)

The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast" or milliseconds.

The optional callback argument is the name of the function executed after the slide is complete.

The following example demonstrates the slideDown () method:

$(document) .ready (function () {$(".flip") .click (function () {$(".panel") .slideDown ("slow");}); div.panel,p.flip {margin:0px; padding:5px; text-align:center; background:#e5eecc; border:solid 1px # c3c3c3;} div.panel {height:120px; display:none;}

W3School-the leading Web technology tutorial site

At W3School, you can find all the website construction tutorials you need.

Please click here

JQuery slideUp () method

The jQuery slideUp () method is used to slide the element up. Syntax:

$(selector) .slideUp (speed,callback)

The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast" or milliseconds.

The optional callback argument is the name of the function executed after the slide is complete.

The following example demonstrates the slideUp () method:

$(document) .ready (function () {$(".flip") .click (function () {$(".panel") .slideUp ("slow");}); div.panel,p.flip {margin:0px; padding:5px; text-align:center; background:#e5eecc; border:solid 1px # c3c3c3;} div.panel {height:120px;}

W3School-the leading Web technology tutorial site

At W3School, you can find all the website construction tutorials you need.

Please click here

JQuery slideToggle () method

The jQuery slideToggle () method can switch between the slideDown () and slideUp () methods.

If elements slide down, slideToggle () slides them up.

If elements slide up, slideToggle () slides them down.

Syntax:

$(selector) .slideToggle (speed,callback)

The optional speed parameter specifies the duration of the effect. It can take the following values: "slow", "fast" or milliseconds.

The optional callback argument is the name of the function executed after the slide is complete.

The following example demonstrates the slideToggle () method:

$(document) .ready (function () {$(".flip") .click (function () {$(".panel") .slideToggle ("slow");}); div.panel,p.flip {margin:0px; padding:5px; text-align:center; background:#e5eecc; border:solid 1px # c3c3c3;} div.panel {height:120px; display:none;}

W3School-the leading Web technology tutorial site

At W3School, you can find all the website construction tutorials you need.

Please click here

This is the end of this article on "how jQuery makes HTML elements slide up and down". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Methods elements parameters tutorials effects examples functions names techniques technical tutorials duration sites articles websites website construction grammar facets post construction demonstrations Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia vpn Shulou Tech Info Shulou Technology Huawei