Loud Links - 给你的网页交互添加音效

1,748 阅读1分钟
原文链接: loudlinks.rocks

The library creates HTML5 audio element and uses it to play mp3/ogg audio files which is currently supported in all browsers.

Examples


Hover over me Click me
It works on anything, even on cat gifs!

Usage


It’s super simple, attach the library to your project and follow these 3 steps:

Step 1

At the root of your website directory create a folder named “sounds” with 2 more folders inside it with the names “mp3” & “ogg”.


Step 2

Add the class “loud-link-hover” to any link/element that you want to give a sound on hover.

<div class=“loud-link-hover”></div>

Or add the class “loud-link-click” to any link/element that you want to give a sound on click.

<div class=“loud-link-click”></div>

Step 3

Add the attribute “src-data” to the element & write in it the name of your sound without the extension.

<div class=“loud-link-hover” src-data=“sound”></div>

Done & Done

Download View on GitHub