<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="jquery-3.2.1.min.js"></script>
</head>
<body>
<div id="div1" class="box">div</div>
<div id="div2" class="box2">div</div>
<div id="div3" class="box">div</div>
<div id="div4" class="box2">div</div>
<script>
$(".box").css("background","purple");
</script>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="jquery-3.2.1.min.js"></script>
</head>
<body>
<li title="bagayalu">1</li>
<li title="youxi">2</li>
<li>3</li>
<li class="box">4</li>
<li class="box">5</li>
<li>6</li>
<script>
$("li").filter(".box").css("background","pink");
$("li").filter("[title=youxi]").css("background","yellow");
$("li").filter("[title=bagayalu]").css("background","orange");
</script>
</body>
</html>