0

I found out that there is a new HTML5 tag. I want a HTML/Javascript code but I dont want any jQuery in it. Its for a html doc which will have music playing automaticaly in the background, i would like the code to make a little mute button in the topleft corner of the screen. Heres the standard code to work on.

<audio controls="?"* loop="loop">
  <source src="horse.wav" type="audio/wave">
</audio>

*: Not sure if to be included

The button may be text or picture and it may change (e.g: mute/unmute or mute then when clicked changes to unmute and back).

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Blob
  • 97
  • 1
  • 1
  • 6
  • may be dupliacte questions http://stackoverflow.com/questions/6442427/muting-a-html5-audio-element-using-a-custom-button http://stackoverflow.com/questions/6376450/how-to-mute-an-html5-video-player – Shahrukh A. Nov 23 '12 at 18:13

1 Answers1

2

This should work:

document.getElementById('background_audio').muted = true;

Demo: http://jsfiddle.net/mattball/sVwXH/ (no jQuery)

Reference

Community
  • 1
  • 1
Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110