I have this.
$(function()
{
$("#test_div").toggle(
function() { $("#test_div").css({"background-color": "#00ff00"}); },
function() { $("#test_div").css({"background-color": "#0000ff"}); }
);
});
According to the documentation, every time I click in the div the functions in toggle should execute in an alternate way. First the function in the first argument should execute and after the second click the function in the second argument should execute.
However, the div just hides. What am I doing wrong?
If you are using jQuery 1.9.0 or later, they removed the toggle event. Try with toggleClass().