[英]How can play mp3 when click on image between <p> </p> tag (html5 code)
In web source I used, when drafting, everything I wrote (by using CKeditor 3.2) is between <p></p>
tag, I can't play mp3 by js. 在我使用的网络源中,起草时,我编写的所有内容(通过使用CKeditor 3.2)都在<p></p>
标记之间,我无法通过js播放mp3。 I need to play mp3 (also on mobile device). 我需要播放mp3(也在移动设备上)。 Formerly, I used <object ... width="20" height="20" >
to play mp3, but it does not work in mobile devices. 以前,我使用<object ... width="20" height="20" >
播放mp3,但在移动设备上无法正常播放。 I need to play mp3 file both in PC and mobile device, and I just drafted in <p> </p>
tag. 我需要同时在PC和移动设备上播放mp3文件,而我只是在<p> </p>
标签中起草了文件。 Somehow for me to play mp3 when click on image ( put between <p>
tag) or how to edit this code to make it width=20, heigh=20
单击图像(放在<p>
标记之间)时如何以某种方式让我播放mp3,或者如何编辑此代码以使其变为width=20, heigh=20
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio tag.
</audio>
Try labeling the audio tag with an id, hide the audio player, then attach an onclick event to the 尝试用id标记音频标签,隐藏音频播放器,然后将onclick事件附加到
tag which contains the image. 包含图像的标签。
sample javascript: 示例javascript:
var audioTagged = document.getElementById('audioID');
audioTagged.src = 'audio.mp3';
audioTagged.load();
sample html: 范例html:
<p onclick="triggerAudio()"><img src="smiley.jpg" /></p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.