javascript - multiple instances of html5 audioElement, can it be done with $(this)? -
how use use multiple instances of on 1 page e.g mysql while loop. if imagine multiple instances of below code, when click 'play' play first instance. need code similar these 3 lines :
$('.play').click(function () { $(this).audioelement.play(); });
but here working code. (javascript)
$(document).ready(function () { var audioelement = document.createelement('audio'); audioelement.setattribute('src', '<?php echo "http://www.2click4.com/mods/wall/uploads/".$rowsound[' file '].""; ?>'); $('.play').click(function () { audioelement.play(); }); $('.pause').click(function () { audioelement.pause(); }); });
(html)
<div class="play">play</div> <div class="pause">stop</div>
of course yes, need native dom element call function since jquery doesn't have idea native play
method. should work you
html
<div class="play"> <audio src="http://www.2click4.com/mods/wall/uploads/1709824424.wav"></audio> play </div> <div class="pause">stop</div>
js
$('.play').click(function () { $('audio', this).get(0).play(); });
Comments
Post a Comment