0 votes
in JQuery by
What is the use of the toggle() method in JQuery?

1 Answer

0 votes
by
If there is a click event, toggle() attaches functions to toggle. So, on first click first action occurs, on second, second action and so on.

<button>Change my color on each click</button>

<script>

$(document).ready(function(){

$("button").toggle(

function(){$("button").css({"color": "blue"});},

function(){$("button").css({"color": "yellow"});},

function(){$("button").css({"color": "red"});

});

});

</script>

Related questions

0 votes
asked Nov 20, 2020 in JQuery by sharadyadav1986
0 votes
asked Jan 9, 2021 in JQuery by SakshiSharma
...