Sarthak Singhal
Sarthak Singhal

Reputation: 161

adding controls to all audio elements on audio elements on document load

<script src="jQuery.js></script>
<script>
var a = document.getElementByTagName("audio");
a.controls = true;
</script>
<audio src ="one.mp3"></audio>
<audio src ="two.mp3"></audio>
<audio src ="three.mp3"></audio>
<audio src ="four.mp3"></audio>
<audio src ="five.mp3"></audio>

The controls still do not appear in the audio? I have twenty such elements

Upvotes: 0

Views: 32

Answers (1)

ram vinoth
ram vinoth

Reputation: 512

You can use either document.ready or window.load to do this

    $(document).ready(function(){
          $("#audio").each(function(){
       $(this).attr("controls","");
});
    });

Upvotes: 1

Related Questions