47
rated 0 times
[
49]
[
2]
/ answers: 1 / hits: 83696
/ 11 Years ago, thu, august 8, 2013, 12:00:00
I have a box without color. if the box is being click()
it will addClass('.red')
to make it red, and if click again the box color change to blue. they change alternatively. and I don't know how to make it.
Code
HTML
<div class='box'></div>
CSS
.box {
width: 250px;
height: 100px;
border: 1px #000 solid;
}
.red {
background: red;
}
.blue {
background: blue;
}
Javascript
$('div').click(function() {
$(this).addClass('red');
});
More From » jquery