Создаем динамический-список меню


задача была такая: собрать все якоря (ссылки) из определенных id на странице и составить из них новое дополнительное меню для быстрого перехода. скрипт:

setTimeout(function () {
jQuery(document).ready(function(jQuery) {
	var spisok = new Array();
	var h3name = new Array();
	
	jQuery('h3 a').each(function() {		
		//text	= jQuery(this);
		h3name.push(jQuery(this).text().toString());
		//console.log(h3name);	
	});
	
	jQuery('div.entry').each(function() {		
		var vsegoh3	= jQuery('h3[id^="ui-accordion"]').length;
		var links 	= jQuery('h3[id^="ui-accordion"]').find('a');
					
		for(var i=0;i<vsegoh3;i++){
			//console.log(i);
			jQuery(links[i]).attr('name','stone'+[i]);
			spisok[i] = '<li><a href="#stone'+[i]+'">'+h3name[i]+'</a></li>';
		}
	//console.log(spisok);
	var html_spisok = spisok.join("");
	//console.log(html_spisok);
	jQuery("div.entry").prepend("Быстрый переход: <ul id='qs'>"+html_spisok+"</ul><br>");
	});
});
}, 1000);