나는 다음과 같은 스타일 :HTML 요소에 마우스 오버 배경색 변경을 구현하는 가장 간단한 방법은 무엇입니까?
a.button {
background-color: orange;
margin: .2cm;
padding: .2cm;
color: black;
font-family: sans-serif;
text-decoration: none;
font-weight: bold;
border: solid #000000;
}
a.buttonMouseover {
background-color: darkGoldenRod;
margin: .2cm;
padding: .2cm;
color: black;
font-family: sans-serif;
text-decoration: none;
font-weight: bold;
border: solid #000000;
}
그리고 다음과 같은 자바 스크립트 코드 (내 최초의 BTW) :
function backgroundChangeIn(element){
if (element.className = "a.button"){element.className = "buttonMouseover";}
}
function backgroundChangeOut(element){
if (element.className = "a.buttonMouseover"){element.className = "button";}
}
그리고, 마우스 커서를 가져다 대면 배경을 변경해야합니다 다음과 같은 요소 :
<a class="button" href="" onmouseover="backgroundChangeIn(this)" onmouseout="backgroundChangeOut(this)">A Button</a>
지금까지 저에게 효과적이었습니다. 그러나 더 좋은 방법이 있는지 궁금해하고있었습니다. (모든 코드에 대한 죄송합니다)
맞춤법 검사 덕분에 – jjnguy