How do I add and remove a class every time I click?
Original Code
HTML:
<div class="box"></div>
CSS:
.box{
width: 100px;
height: 100px;
background: blue;
}
I want to add:
.rounded {
border-radius: 10px;
}
I know I have to use the click function on the box div, but I don't know how to add a class and remove it.
Answer:
Use the toggleClass
$(".box").click(function(){
$(this).toggleClass("rounded");
});