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:
jQuery code:
$("p").toggle()
Result:
② 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
JQuery
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
JQuery code
$("#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