LouisWhit
7/11/2013 - 12:59 PM

Dynamic FAQ Maker - HTML has bootstrap tags in it. It is output after the DOM loads by JS that reads the page for h3 tags and dynamically cr

Dynamic FAQ Maker - HTML has bootstrap tags in it. It is output after the DOM loads by JS that reads the page for h3 tags and dynamically creates the FAQ.

var ToC =
    "<div class='well table-of-contents'>" +
      "<h2>Question's List:</h2>" +
      "<p>Click on any of the questions to go their corresponding answers below or you may just scroll down the page to find the answers you are looking for.</p>"+
      "<ul>";
        var newLine, el, title, link, id, i = 0;
        $('.second-level-content .span8 h3').each(function(){
          el = $(this);
          title = el.text();
          i = i+1;
          id = 'FAQ' + i
          el.addClass('relative');
          el.prepend("<span id='"+id+"' style='position:absolute;top:-50px;'></span>")
          el.append("&nbsp;&nbsp;&nbsp;<a class='faq-link' href='#custom1_mod'>Back to Top &uarr;</a>")
          link = "#" + id;
             newLine =
              "<li>" +
              "<a href='" + link + "'>" +
              title +
              "</a>" +
              "</li>";
          ToC += newLine;
        });
      ToC +=
      "</ul>" +
    "</div><div class='row-fluid'><div class='span-12 dashes'>&nbsp;</div></div>";

$(".span8 h1").after(ToC);