<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{margin: 0; padding: 0; list-style: none;}
ul {
text-align: center;
}
li {
width : 50px;
height: 50px;
background-color: #ccc;
border-radius: 50%;
display: inline-block;
margin: 50px 10px;
}
</style>
</head>
<boby>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<script src="js/jquery-3.6.0.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script>
var onClick = true;
var arr = ["red", "green", "blue", "yellow", "black"];
// $("ul li").on("click", function() { //class 호출 시에만 .을 사용함
// if(onClick == true) {
// $(this).css("backgroundColor", arr[0]);
// } else if(onClick == true) {
// $(this).siblings().css("backgroundColor", arr[1]);
// } else if(onClick == true) {
// $(this).css("backgroundColor", arr[2]);
// } else if(onClick == true) {
// $(this).css("backgroundColor", arr[3]);
// } else if(onClick == true) {
// $(this).css("backgroundColor", arr[4]);
// }
// });
$("ul li").on("click", function() { //class 호출 시에만 .을 사용함
$(this).siblings().css("backgroundColor", "red").siblings().css("backgroundColor", "#ccc");
});
</script>
</boby>
</html>