따라서이 코드는 article
요소 위로 마우스를 가져 가면 오디오 클립이 재생됩니다. 문제는 마우스가 자식 요소를 가리키면 멈추는 것입니다. 마우스를 일반 article
요소에서 자식 요소 위로 가져 가면 Stopsound 기능이 실행되지 않도록하려면 어떻게해야합니까?마우스를 특정 요소로 움직일 때 Onmouseout이 실행되지 않습니까?
편집 : 기본적으로 나는 당신이 마우스를 가져다 놓은 자식 요소 중 하나를 번갈아 전환 할 때 어떤 기능도 실행하지 않기를 바란다. here 설명으로 .hover
jQuery의 함수를 사용
function PlaySound(soundobj) {
var thissound = document.getElementById(soundobj);
thissound.play();
}
function StopSound(soundobj) {
var thissound = document.getElementById(soundobj);
thissound.pause();
thissound.currentTime = 0;
}
* {
margin: 0;
padding: 0;
}
article24 {
width: 50px;
height: 100px;
background-color: green;
}
#box24 {
width: 50px;
height: 50px;
background-color: blue;
}
#present24 {
width: 50px;
height: 50px;
background-color: red;
}
#bauble24 {
width: 10px;
height: 10px;
}
<audio id='mySound' src="http://www.freesound.org/data/previews/278/278903_3546642-lq.mp3"></audio>
<article id="article24" onmouseover="PlaySound('mySound')" onmouseout="StopSound('mySound')">
<div id="box24">
<h2></h2>
</div>
<div id="present24">
<a href="">
<div id="bauble24">
<p id="belle24">""</p>
</div>
</a>
</div>
</article>
Brilliant! 가장 간단한 솔루션이 항상 최고입니다. – student42
이것은 큰 거래는 아니지만 클립 재생이 끝난 후 마우스를 올려 놓은 하위 요소를 변경하면 다시 시작됩니다. 비슷한 간단한 수정 방법을 알고 있습니까? 머리 꼭대기에 아무것도 없다면, 자신을 괴롭히지 마라. – student42