排他思想:
想要多选一的效果,当前元素设置样式,其他兄弟元素清除样式即可
Demo:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Jquery中的排他思想</title>
<script src="../../js/jquery.min.js"></script>
<script>
$(function(){
$('button').on('click',function(){
$(this).css('background','pink');
$(this).siblings('button').css('background','');;
});
});
</script>
</head>
<body>
<div class="box">
<button>快速</button>
<button>快速</button>
<button>快速</button>
<button>快速</button>
<button>快速</button>
<button>快速</button>
<button>快速</button>
</div>
</body>
</html>