Posted By

certainlyakey on 05/22/10


Tagged

menu jquery lists


Versions (?)

Automatically create drop-down menu with links to the list items at the beginning of long lists


 / Published in: jQuery
 

The name of the link should be in strong (or you may change this in the script)

  1. $('#publications').prev(':header').css('float','left');
  2. $('#publications').before('<select id="toc" class="jumpmenu"></select>');
  3. $("#publications li strong").each(function(i) {
  4. $(this).attr("id", i+1);
  5. $("#toc").append("<option value='#"+(i+1)+"'>"+$(this).text()+"</option>");
  6. });
  7. $(".jumpmenu").change(function() {
  8. window.location.href = $(this).val();
  9. });

Report this snippet  

You need to login to post a comment.