Home > Web Front-end > JS Tutorial > jQuery effect slideToggle() method (switch between hiding and showing)_jquery

jQuery effect slideToggle() method (switch between hiding and showing)_jquery

WBOY
Release: 2016-05-16 18:05:26
Original
1112 people have browsed it

Example
Switch between showing and hiding the

element by using the sliding effect:

Copy code Code As follows:

$(".btn1").click(function(){
$("p").slideToggle();
});


Definition and Usage
slideToggle() method switches the visible state of an element by using a sliding effect (height change).

Hide the selected elements if they are visible, and show them if the selected elements are hidden.

Syntax
$(selector).slideToggle(speed,callback) Parameter Description
speed Optional. Specifies how quickly an element goes from hidden to visible (or vice versa). Default is "normal".

Possible values:

milliseconds (e.g. 1500)
"slow"
"normal"
"fast"
In case of setting speed, element During the switching process, it will gradually change its height (this will create a sliding effect).

callback optional. The function to be executed after the toggle function is executed.

To learn more about callbacks, visit our jQuery Callback chapter.

This parameter cannot be set unless the speed parameter is set.


Tips and Notes
Tip: If the element is already hidden, the effect will not produce any change unless a callback function is specified.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template