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

[javascript]
$(‘#publications’).prev(‘:header’).css(‘float’,’left’);
$(‘#publications’).before(‘<select id="toc" class="jumpmenu"></select>’);
$("#publications li strong").each(function(i) {
$(this).attr("id", i+1);
$("#toc").append("<option value=’#"+(i+1)+"’>"+$(this).text()+"</option>");
});
$(".jumpmenu").change(function() {
window.location.href = $(this).val();
});
[/javascript]

Leave a Reply