<html>
<head>
<script>
function show_function() {
var example_image=document.getElementById("example_image");
example_image.src="example_one.png";
}
function hide_function() {
var example_image=document.getElementById("example_image");
example_image.src="example.png";
}
</script>
</head>
<body>
<div class="one" onmouseover="show_function()" onmouseout="hide_function()">
<img id="example_image" src="example.png">
</div>
<div class="two" onmouseover="show_function()" onmouseout="hide_function()">
<img id="example_image" src="example.png">
</div>
</body>
</html>
첫 번째 div 위에 마우스를 올려 놓으면 이미지가 변경됩니다. 하지만 두 번째 div 위에 마우스를 올리면 첫 번째 div의 이미지도 변경됩니다.여러 요소에서 onmousehover 이벤트를 사용하는 방법?
누구나 자바 스크립트에서만 그것을 수행하는 방법을 알고 있습니까?
ID는 고유 – DaniP
패스'인수로 this'해야? –
"this"를 함수 매개 변수로 전달한 다음 함수 내에서이 요소를 사용하여 원하는 요소/인접 요소를 대상으로 지정합니다. – n1kkou