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

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

问题描述

我试图让 jQuery 在元素悬停/点击时播放声音.(就像没有flash的flash网站)

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

我已经尝试了 Cross 中推荐的方法- 平台,跨浏览器的方式从 Javascript 播放声音?,jQuery Sound 插件和其他几个教程没有任何成功.我假设这是因为它们自 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天全站免登陆