跨平台,跨浏览器的方式使用jQuery 1.4播放声音? [英] Cross-platform, cross-browser way to play sound using jQuery 1.4?

查看:186
本文介绍了跨平台,跨浏览器的方式使用jQuery 1.4播放声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让jQuery来玩元素悬停/点击声音。 (这就像一个Flash网站不使用闪光灯)

I'm trying to get jQuery to play a sound on element hover/click. (It's like a flash website without flash)

我试过在<一个推荐的方法href=\"http://stackoverflow.com/questions/187098/cross-platform-cross-browser-way-to-play-sound-from-javascript\">Cross-platform,跨浏览器的方式从Javascript播放声音?,jQuery的声音插件,没有任何成功的几个其他教程。我假设这是因为他们没有被自2008年更新。

I've tried the methods recommended in Cross-platform, cross-browser way to play sound from Javascript?, the jQuery Sound plugin and a couple of other tutorials without any success. I'm assuming this is because they haven't been updated since 2008.

有没有人有什么建议?

推荐答案

不需要任何这些。 HTML标记,使用JavaScript结合起来,就可以了。

Don't need any of those. The HTML tag, combined with JavaScript, will do the trick.

<audio id="soundHandle" style="display: none;"></audio>
<script>
  soundHandle = document.getElementById('soundHandle');
  soundHandle.src = '/blah/blah.mp3';
  soundHandle.play();
</script>

这篇关于跨平台,跨浏览器的方式使用jQuery 1.4播放声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆