HTML 페이지의 테이블은 한 줄씩 표시될 수 있습니다. 물론 div에 마우스를 놓으면 색상이 변경되도록 설정할 수도 있습니다.
다음과 같이 코드 코드를 복사합니다.
<스크립트 유형="텍스트/자바스크립트">
var currentActiveRow; //현재 활성 행
//선택한 행의 색상을 변경합니다.
함수 변경ActiveRow(obj) {
if (현재ActiveRow) {
currentActiveRow.style.BackgroundColor = "";
}
currentActiveRow = obj;
currentActiveRow.style.BackgroundColor = "#F2F2F2";
}
</script>
그런 다음 td의 onmousehover 또는 onclick 이벤트를 onmouseover="changeActiveRow(this)"로 설정합니다.