mercredi 20 juillet 2016

On second click; jQuery

<div class="example">
 Test
</div>

$('.example').click(function(){
 $(this).css('color','red');
});

When the code above get's clicked, it will apply the .css. Now what I need is for another bit of code (let's say $(this).css('color','blue');) to be applied, replacing the previous code when .example gets clicked a second time.

I've searched for this and askers seem to only need .show/.hide events which can be substituted with .toggle, which is obviously not the case here.

Aucun commentaire:

Enregistrer un commentaire