0

Does anyone knows how to create a link to every header (h3) SHOWING his respective content in jquery-ui accordion? from the same and from other pages of the website.

i know i can put a name to tag content but what should i do when the link is in other page? , i been thinking , wouldn't be a problem , i will use link like mywebsite.com/index.php#nameofthecontent1 ... but so far i realize isn't possible. So if i have to put trigger for every content (they are 30 and growing) on different pages sound little silly.

Thanks in advance

MikZuit
  • 684
  • 5
  • 17

2 Answers2

0

Your question is a bit vague but are you looking for something like below? I am using a ajax get request to load an external file content into that accordion container. accord3.html is just a sample file I created.You can always use chrome developer tools or firebug to inspect the HTML structure.

     $("h3 a").on('click', function(){
            var self = $(this);
            var url = $(this).text();
            $.get(url + ".html", function(data){

                self.parent().next("div").html(data);   
            });

        });
DG3
  • 5,070
  • 17
  • 49
  • 61
0

You can emulate clicking on a section by doing something like:

var sectionId = "id-of-the-section-you-want"; // get this from the query string
$('#' + sectionId).click();

This should open the section you want. Here's an article on getting the query string values from javascript: How can I get query string values in JavaScript?

Community
  • 1
  • 1
egbrad
  • 2,387
  • 2
  • 23
  • 27