Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8945207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:11:44+00:00 2026-06-15T12:11:44+00:00

I have the following code which I was using to attempt to dynamically add

  • 0

I have the following code which I was using to attempt to dynamically add jplayers via a function.

function audio_player(audio, title, type) {

    var id = $('.audio').length;

    $('#audio').append('<div id="jquery_jplayer_'+id+'" class="audio"></div><div id="jp_container_'+id+'" class="jp-audio"><div class="jp-type-single"><div class="jp-gui jp-interface"><ul class="jp-controls"><li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li><li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li><li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li><li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li><li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li><li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li></ul><div class="jp-progress"><div class="jp-seek-bar"><div class="jp-play-bar"></div></div></div><div class="jp-volume-bar"><div class="jp-volume-bar-value"></div></div><div class="jp-time-holder"><div class="jp-current-time"></div><div class="jp-duration"></div></div></div><div class="jp-title"><ul><li>'+title+'</li></ul></div><div class="jp-no-solution"><span>Update Required</span>To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.</div></div></div>');


    $("#jquery_jplayer_"+id).jPlayer({
        ready: function () {
            $(this).jPlayer("setMedia", {
                mp3: audio
            });
        },
        play: function() { // To avoid jPlayers playing together.
            $(this).jPlayer("pauseOthers");
        },
        swfPath: "../js",
        cssSelectorAncestor:"#jp_container_"+id,
        supplied: type,
        errorAlerts: true,
        warningAlerts: false,
        wmode:"window"
    });
}


$(document).ready(function() {
    audio_player("http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3", "Test Title", "mp3");
    audio_player("http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3", "Test2 Title", "mp3");
});

With this code I am getting the error

TypeError: $(...).jPlayer is not a function 

wmode:"window"

When I use the same code, only set up as they have it in their demos (all the javascript inside document.ready() and statically declared) everything works fine.

Any ideas on what’s going wrong/how to fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:11:45+00:00Added an answer on June 15, 2026 at 12:11 pm

    Ended up solving it by doing this:

    $(document).ready(function() {
        function audio_player(audio, title, type) {
    
          var id = $('.audio').length;
    
          $('#audio').append('<div id="jquery_jplayer_'+id+'" class="audio" data-file="'+audio+'" data-type="'+type+'"></div><div id="jp_container_'+id+'" class="jp-audio"><div class="jp-type-single"><div class="jp-gui jp-interface"><ul class="jp-controls"><li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li><li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li><li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li><li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li><li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li><li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li></ul><div class="jp-progress"><div class="jp-seek-bar"><div class="jp-play-bar"></div></div></div><div class="jp-volume-bar"><div class="jp-volume-bar-value"></div></div><div class="jp-time-holder"><div class="jp-current-time"></div><div class="jp-duration"></div></div></div><div class="jp-title"><ul><li>'+title+'</li></ul></div><div class="jp-no-solution"><span>Update Required</span>To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.</div></div></div>');
    
          $('#jquery_jplayer_'+id).jPlayer({
              ready: function(event) {
                  $(this).jPlayer("setMedia", {
                      mp3: $(this).attr('data-file')
                  });
              },
              play: function() { // To avoid both jPlayers playing together.
                  $(this).jPlayer("pauseOthers");
              },
              swfPath: js,
              cssSelectorAncestor:'#jp_container_'+id,
              supplied: type,
              errorAlerts: true,
              warningAlerts: false,
              wmode:"window"
          });
        }
    
        audio_player("file.mp3", "Test Title", "mp3");
        audio_player("file2.mp3", "Test2 Title", "mp3");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code below in which I am using to attempt to
I have the following code which outputs an object to an XML file: using
I have the following code alternatives, neither of which is satisfactory. I'm using jQuery
I have a javascript code using which I want to accomplish the following .
i have the following code which switches some fullscreen-background-images (fadeOut, fadeIn). setInterval(function() { var
I have folowing code in which i am using some conditions on page to
I have following code which works for radio buttons but need to be changed
I want to know is below code correct ? I have following code which
I have the following code which definitely returns a proper data result if I
I have the following code which is working, I was wondering if this can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.