banu prakash banu prakash - 1 year ago 61
CSS Question

how to get audio on clickeing the image using javascript and pause when playing

<img class="cl"src="photo/198.jpg"/></br>
<audio class="cs" controls>
<source src="audio/198 banu nagamothu.mp3" type="audio/mpeg">

I dont want controls to audio first but when i clicked the image audio should played using javascript and html

Answer Source

Use AudioElement.paused property!

$('.cl').click(function() {
  var DOMElem = $('.cs').get(0);
  DOMElem.paused ? : DOMElem.pause();
<script src=""></script>
<img class="cl" src="photo/198.jpg" />
<audio class="cs">
  <source src="" type="audio/mpeg">

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download