html5 audio player - jquery toggle click play/pause?

前端 未结 15 2461
南笙
南笙 2020-11-28 06:24

i wonder what i\'m doing wrong?

    $(\'.player_audio\').click(function() {
    if ($(\'.player_audio\').paused == false) {
        $(\'.player_audio\').paus         


        
15条回答
  •  情书的邮戳
    2020-11-28 06:47

    Well, I'm not 100% sure, but I don't think jQuery extends/parses those functions and attributes (.paused, .pause(), .play()).

    try to access those over the DOM element, like:

    $('.player_audio').click(function() {
      if (this.paused == false) {
          this.pause();
          alert('music paused');
      } else {
          this.play();
          alert('music playing');
      }
    });
    

提交回复
热议问题