How do we attach toggle element ?

 Posted by Vivek.Ramapuram on 6/15/2015 | Category: jQuery Interview questions | Views: 2908 | Points: 40

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.
  $("#divToggle").toggle(function () {

$(this).css("background", "blue");
}, function () {
$(this).css("background", "Brown");
function () {
$(this).css("background", "");

Asked In: While Learning | Alert Moderator 

Comments or Responses

Login to post response