点击增加删除class
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>点击增加删除class</title>
<style>
.box{
width: 100px;
height: 100px;
background-color: blue;
}
.active {
background-color: red;
}
</style>
</head>
<body>
<div class="box"></div>
<script src="../plugins/jquery-1.10.1.min.js"></script>
<script>
var $sel = $(".box");
$sel.click(function (e) {
e.stopPropagation();
$(this).toggleClass("active");
});
</script>
</body>
</html>