Sunday, October 2, 2011

toggle()

toggle(Function even, Function odd) returns jQuery
Toggle between two function calls every other click. Whenever a matched element is clicked, the first specified function is fired, when clicked again, the second is fired. All subsequent clicks continue to rotate through the two functions.

Use unbind("click") to remove.

Example:


$("p").toggle(function(){
$(this).addClass("selected");
},function(){
$(this).removeClass("selected");
});

No comments:

Post a Comment