Toggle between three classes in jquery

by Faisal Khan Janjua

HTML

<p>Click the element below</p>

<div class="two"></div>

CSS

.one:before  { content: "class one"; color: blue; }
.two:before  { content: "class two"; color: green; }
.three:before  { content: "class three"; color: red; }

div { width: 100px; border: 1px green solid;  }

JavaScript

$('.one, .two, .three').click(function() {                             
    this.className = {
       three : 'one', one: 'two', two: 'three'
    }[this.className];
});