Use HTML5 to add a mouse hover audio effect without FLASH

Source: Internet
Author: User

Comments: You can use HTML5 + jQuery to add a hover sound effect. It is compatible with Firefox 3.5 + and Chrome 3 +. You can use the html5 audio element to randomly play an mp3 sound effect, for more information about how to use HTML5 + jQuery, do not use FLASH:

Browser: Firefox 3.5 +, Chrome 3 +, Opera 10.5 +, Safari 4 +, IE 9 +

Sample Code:

The Code is as follows:
$ ("# Speak"). mouseenter (function (){
$ ("<Audio> </audio>"). attr ({
'Src': 'audio/'+ Math. ceil (Math. random () * 5)+'hangzhou ',
'Volume ': 0.4,
'Autoplay': 'autoplay'
}). AppendTo ("body ");
});

The above uses the html5 audio element to randomly play an mp3 sound effect.

This code example (jQuery is used) comes from the goodfootapp.com homepage.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.