The toggle() method toggles between hide() and show() for the selected elements.This method checks the selected elements for visibility. show() is run if an element is hidden. hide() is run if an element is visible - This creates a toggle effect.
Syntax:
$(selector).toggle(speed,easing,callback)
|
Example:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").toggle();
});
});
</script>
</head>
<body>
<p>This is a paragraph.:- hi friedns How Are You ?</p>
<button>click me to Toggle between hide() and show()</button>
</body>
</html>
|