gpt4 book ai didi

html - 我如何在按钮菜单上添加声音

转载 作者:太空宇宙 更新时间:2023-11-04 12:11:05 25 4
gpt4 key购买 nike

HTML:

<!DOCTYPE html>
<head>
<meta charset="UTF-8">
</head>

<body>
<div class="buttons" >
<li><pre><strong><a href="home.html">Home</a></strong> </pre></li>
</div>
</body>

CSS:

.buttons{
font-size:16px;

position:fixed;
bottom:217px;
left:183px;
}

这是我的代码,没有任何声音,我怎样才能在上面输入声音?

最佳答案

你可以使用这个 jQuery 代码:

  $(document).ready(function() {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'audio.mp3');
audioElement.setAttribute('autoplay', 'autoplay');
//audioElement.load()

$.get();

audioElement.addEventListener("load", function() {
audioElement.play();
}, true);

$('.play').click(function() {
audioElement.play();
});

$('.pause').click(function() {
audioElement.pause();
});
});

和 Controller 的 HTML:

<div class="play">Play</div>

<div class="pause">Stop</div>

下次请使用搜索:

Play an audio file using jQuery when a button is clicked

关于html - 我如何在按钮菜单上添加声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29043026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com