Answer: We attach toggle events that fires in alternate clicks
From the below example when “divToggle” will be clicked for the first time the background will become blue, the next time background will become brown and when clicked again it will be transparent and again will repeat the same.
Example:
$("#divToggle").toggle(function () {
$(this).css("background", "blue");
}, function () {
$(this).css("background", "Brown");
},
function () {
$(this).css("background", "");
});
Asked In: While Learning |
Alert Moderator