How jQuery makes HTML elements slide up and down
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.