Home > Web Front-end > JS Tutorial > jQuery hide and show effect implementation_jquery

jQuery hide and show effect implementation_jquery

WBOY
Release: 2016-05-16 15:06:31
Original
1248 people have browsed it

Example

jQuery hide()

Simple jQuery hide() method demonstration.

jQuery hide()

Another hide() instance. Demonstrates how to hide text.

jQuery hide() and show()

With jQuery, you can hide and show HTML elements using the hide() and show() methods:

Example

$("#hide").click(function(){
$("p").hide();
});
$("#show").click(function(){
$("p").show();
});
Copy after login

Grammar:

$(selector).hide(speed,callback);
$(selector).show(speed,callback);
Copy after login

The optional speed parameter specifies the speed of hiding/showing, and can take the following values: "slow", "fast" or milliseconds.

The optional callback parameter is the name of the function to be executed after hiding or showing is completed.

The following example demonstrates the hide() method with the speed parameter:

Example

$("button").click(function(){
$("p").hide(1000);
});
Copy after login

jQuery toggle()

With jQuery, you can use the toggle() method to toggle the hide() and show() methods.

Show hidden elements and hide displayed elements:

Example

$("button").click(function(){
$("p").toggle();
});
Copy after login

Grammar:

$(selector).toggle(speed,callback);
Copy after login

The optional speed parameter specifies the speed of hiding/showing, and can take the following values: "slow", "fast" or milliseconds.

The optional callback parameter is the name of the function to be executed after the toggle() method completes.

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