I have a click event lets take this example:
$('p').click( function() {
$('.xclass').css( { 'background' : 'green' } );
});
The above code will change the background color of a div if I click the p tag.
Now my question is again clicking the same p tag I want to change the color to yellow!!. How can I do this?.
Change a variable after the first click, to know that you’ve clicked it once before. I prefer using data() over globals, but variables demonstrates it better.