<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<script>
// JS basic
// 주석은 똑같아아
// function test(element){ // --> test라는 함수명을 가지며, 하나의 매개변수 element를 받습니다. 함수 내에서 element는 전달된 HTML 요소를 나타냅니다.
// element.setAttribute("class", "bi bi-heart-fill text-danger fs-1");
// // --> setAttribute 메서드를 사용하여 class 속성을 "bi bi-heart-fill text-danger"로 설정
// }
function test(element){
var attr = element.getAttribute("class");
if(attr == "bi bi-heart-fill text-danger fs-1"){
element.setAttribute("class", "bi bi-heart text-danger fs-1")
}else{
element.setAttribute("class", "bi bi-heart-fill text-danger fs-1")
}
}
</script>
</head>
<body>
<div class="container">
<i onclick="test(this)" class="bi bi-heart text-danger fs-1"></i>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
crossorigin="anonymous"></script>
</body>
</html>