I am trying to create a audio
tag in javascript.
I have the following
this.audioElement = createElement('audio', {className:'audio', src:'test.mp3', type:'audio/mpeg'});
The audio tag I want to appear in html
<audio controls src='test.mp3' type='audio/mpeg'></audio>
I am not sure how to create controls
attribute in js. Can anyone help me about it? Thanks!
Advertisement
Answer
got it now.
this.audioElement = createElement('audio', {className:'audio-asset', src:'test.mp3'}); this.audioElement.setAttribute('controls',true);