Home > Web Front-end > JS Tutorial > Use JQuery's toggle to implement automatic pop-up windows after web page loading_jquery

Use JQuery's toggle to implement automatic pop-up windows after web page loading_jquery

WBOY
Release: 2016-05-16 16:55:17
Original
1301 people have browsed it

toggle() event It mainly switches the visible state of the element.

1. toggle (switch) ①switch is an optional value. If it is not filled in, the original element will be hidden if it is displayed. If it is hidden, it will be displayed.

HTML code:

Copy code The code is as follows:

Hello Again



jQuery code:
Copy code The code is as follows:

$("p").toggle()

Result:
Copy code The code is as follows:

Hello

Hello Again



② switch If there is a value, it is TRUE or false. If it is TRUE, the element is displayed, and FALSE hides the element.
HTML
Copy code The code is as follows:

Hello




JQuery
Copy code The code is as follows:

var i = 0;
$("#b").click(function(){
$("#tt").toggle(i %2==0);
});

2. toggle(speed, [callback]) speed is optional The parameter represents the speed of element animation. The element is displayed or hidden in the "sliding" manner of animation. Its value can be (slow, normal, fast); [callback] is a method that the function can execute.

HTML code
Copy code The code is as follows:



JQuery code
Copy code The code is as follows:

$("#t").toggle("slow",function(){
alert("123456");
} );

That is: when using the second method, hiding the speed can automatically load the web page and pop up the screen
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