鼠标移到指定位置听音乐javascript,play sound on hover. stop and reset on hoveroff

来源:互联网 发布:淘宝国产高达禁卖 编辑:程序博客网 时间:2024/06/07 20:02

目标:
鼠标移动到指定位置,音乐从头播放;
鼠标移开,音乐停止播放;

<script>function PlaySound(soundobj) {    var thissound=document.getElementById(soundobj);    thissound.play();}function StopSound(soundobj) {    var thissound=document.getElementById(soundobj);    thissound.pause();    thissound.currentTime = 0;}</script><p onmouseover="PlaySound('mySound')"     onmouseout="StopSound('mySound')">Hover Over Me To Play</p><audio id='mySound' src='http://upload.wikimedia.org/wikipedia/commons/6/6f/Cello_Live_Performance_John_Michel_Tchaikovsky_Violin_Concerto_3rd_MVT_applaused_cut.ogg'/>

stackoverflow原贴链接点这里

0 0