$(".btn1").click(function(){ $("p").hide();});
toggle() method switches the visible state of an element.
If the selected elements are visible, then hide these elements. If the selected elements are hidden, then display these elements.
$(selector).toggle(speed,callback,switch)
Parameters | Description |
---|---|
speed |
Optional. Specifies how quickly an element goes from visible to hidden (or vice versa). Default is "0". Possible values:
When the speed is set, during the process of the element going from visible to hidden, Gradually changes its height, width, margins, padding, and transparency. If this parameter is set, the switch parameter cannot be used. |
callback |
Optional. The function to be executed after the toggle function is executed. To learn more about callbacks, visit our jQuery Callback chapter. This parameter cannot be set unless the speed parameter is set. |
switch | ##Optional. Boolean value. Specifies whether toggle hides or shows all selected elements.
|
$("p").toggle(1000);
});
$(".btn1").click(function(){
$("p").toggle(true);
});
} );
The above is the detailed content of jQuery effect - toggle() method introduction. For more information, please follow other related articles on the PHP Chinese website!