SCRIPT AND HTML CODE: When i click on a button, the other buttons are working. I've one class for buttons so how can i use multiple this button ? Shall i add data_id for each button ?
Is this what you need?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <audio controls> <source src="http://www.noiseaddicts.com/samples_1w72b820/4160.mp3" id="audio" type="audio/ogg"> Your browser does not support the audio element. </audio>
Try adding a new class to the tag. And get the element on your JQuery by the new class, like this:
function play() { var audio = document.getElementById('audio'); if (audio.paused) { audio.play(); $('.play-button').addClass('icon-control-pause') $('.play-button').removeClass('icon-control-play') }else{ audio.pause(); $('.play-button').addClass('icon-control-play') $('.play-button').removeClass('icon-control-pause') } }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <audio src="audio.mp3" id="audio"></audio> <i class="play-button icon-control-play i-2x" id="play" onclick="play()"></i>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.