2
기본적으로 bgColor 클래스를 켜기/끄기로 전환하는이 스크립트를 사용하면 첫 번째 단추 클릭시 배경이 검은 색으로 바뀌고 두 번째 클릭시 기본 빈 클래스로 돌아갑니다. 내가 알아 내려고하는 것은 오페라 9.64에서 버튼을 3 번 클릭하면 배경이 검은 색으로 유지되고 버튼 주변의 배경 만 색이 바뀌는 이유입니다.Opera에서 body 요소 클래스 변경
<style>
.bgColor {background-color: #000000}
</style>
<button id="button">Change Class</button>
<script>
function changeBodyClass() {
var body = document.body;
if (body.className === "bgColor") {
body.className = "";
} else {
body.className = "bgColor";
}
}
document.getElementById("button").onclick = changeBodyClass;
</script>
감사합니다.