Search code examples
javascriptjqueryhtmlajaxaudiojs

Script doesn't run after load a div with ajax


I have the script audiojs for changing the style of audios tag in html when I go to my page it work without problems, but when I click a button to reload div (this div contain audios tags) with function load jQuery the style of audiojs removed, I tried to get script after load the div with jQuery getScript, but the script load many times that caused to stop of my browser.

this is the function to call the audiojs

audiojs.events.ready(function() {
  audiojs.createAll();
});

I want a solution to call this function one time no more, thanks


Solution

  • Thanks everyone,

    i found the solution,

    after loading the div with ajax i added this code to remove the class audiojs

    $("audio").removeClass("audiojs");