Home > Article > Web Front-end > How to add background music to button using JS
How to add background music to the button? This article mainly introduces the JS implementation button to add background music sample code. Friends who need it can refer to it. I hope it can help everyone.
1-Code
<html> <head> <meta charset="utf-8"> <title>js实现按键声</title> </head> <body> <ul> <li> <a href="menu-list" rel="external nofollow" rel="external nofollow" rel="external nofollow" >主页</a> </li> <li> <a href="menu-list" rel="external nofollow" rel="external nofollow" rel="external nofollow" >详情</a> </li> <li> <a href="menu-list" rel="external nofollow" rel="external nofollow" rel="external nofollow" >列表</a> </li> </ul> <script language="javascript"> $(function() { $('menu-list').click(function() { $('btn-bgm').remove(); $('body').append('<embed src="button.wav" autostart="true" hidden="true" loop="false" class = "btn-bgm">'); }); }); </script> </body> </html>
2-Description
Bind the node in advance Define the event and click to add background music.
Related recommendations:
About the implementation of the automatic playback effect of background music in h5
Set background music for the web page_html/css_WEB-ITnose
php page Add background music to control stop/play
The above is the detailed content of How to add background music to button using JS. For more information, please follow other related articles on the PHP Chinese website!