Using JQuery toggle to realize automatic popover of page loading
- 2020-03-30 02:25:55
- OfStack
The toggle() event primarily toggles the visible state of the element.
1, toggle (switch) switch is an optional value, if not filled in the original element is shown to hide it, if it is hidden to show.
HTML code:
JQuery code:
Results:
Switch if there is a value is TRUE or false, if it is TRUE to show the element, false hidden elements.
HTML
JQuery
2. Toggle (speed, [callback]) speed is an optional parameter, which represents the speed of element animation. [callback] is a method that a function can execute.
The HTML code
JQuery code
That is, when using the second method, hidden speed can be used to load the page automatically pop-up screen
1, toggle (switch) switch is an optional value, if not filled in the original element is shown to hide it, if it is hidden to show.
HTML code:
<p>Hello</p><p style="display: none">Hello Again</p>
JQuery code:
$("p").toggle()
Results:
<p tyle="display: none">Hello</p><p style="display: block">Hello Again</p>
Switch if there is a value is TRUE or false, if it is TRUE to show the element, false hidden elements.
HTML
<p id = "tt">Hello</p>
<input type="button" value=" transform " id="b">
JQuery
var i = 0;
$("#b").click(function(){
$("#tt").toggle(i++%2==0);
});
2. Toggle (speed, [callback]) speed is an optional parameter, which represents the speed of element animation. [callback] is a method that a function can execute.
The HTML code
<p style="display: none" id = "t">Hello Again</p>
JQuery code
$("#t").toggle("slow",function(){
alert("123456");
});
That is, when using the second method, hidden speed can be used to load the page automatically pop-up screen