I seem to be stuck here. I have an HTML page loading content dynamically—one of the "pages" loaded contains an accordion presenting the paragraphs on click.
Now I would like to implement the corresponding JavaScript / jQuery to make the accordion work. So far I had implemented the jQuery in the footer—problem is, that it would look for elements that are not loaded yet. This is what I have:
jQuery(document).on("click", "#acc1", function(){
jQuery(this).next("dd").slideToggle("fast");
})
This does work perfectly fine when opening a "static" url for that page—but not if the page is loaded dynamically. The #acc1
isn't loaded when the jQuery is loaded—so it can't be bound to that id yet. I hope I made my problem clear? Thank you very much! I would appreciate all suggestions / pointers …