Use JQuery's toggle to automatically load webpages _ jquery

Source: Internet
Author: User
The toggle () event mainly switches the visible state of elements. The following describes how to use JQuery's toggle to automatically display the toggle () event after webpage loading. It mainly switches the visible state of elements.

1. toggle (switch) ① switch is an optional value. If this parameter is left blank, the original element is displayed and hidden.

HTML code:

The Code is as follows:


Hello

Hello Again



JQuery code:

The Code is as follows:


$ ("P"). toggle ()


Result:

The Code is as follows:


Hello

Hello Again



② If the switch has a value, the value is TRUE or false. If the switch is TRUE, the element is displayed. If the switch has a value, the element is hidden.
HTML

The Code is as follows:


Hello




JQuery

The Code is as follows:


Var I = 0;
$ ("# B"). click (function (){
$ ("# Tt"). toggle (I ++ % 2 = 0 );
});


2. toggle (speed, [callback]) speed is an optional parameter. It indicates the animation speed of an element. The element is displayed or hidden by sliding the animation, its value can be (slow, normal, fast); [callback] is the method that can be executed by the function.

HTML code

The Code is as follows:


Hello Again



JQuery code

The Code is as follows:


$ ("# T"). toggle ("slow", function (){
Alert ("123456 ");
});


That is, when the second method is used to hide speed, the page can be loaded to automatically play the screen.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.