[jQuery] wrap() issue

[jQuery] wrap() issue


hi!
i'm trying to create a menu on the fly, by parsing selectors and
creating a unordered list, but i must be getting the wrap(() function
wrong as that bit does not get generated:
$('<ul id="mainmenu_level2" class="mycarousel mainmenu
jcarousel-skin-labau">').appendTo('#header');
$('#dsViewport h3').each(function(index){
             var $this = $(this);
             $('<a></a>')
             .attr({
                'title': 'jump to ' + $this.text(),
                'href': '#' + $this.text()
             })
.wrap('<li></li>')
             .text($this.text())
             .attr('id', 'pc-' + index)
            
             .appendTo('#mainmenu_level2');
});
in the generated html, the a elements are created, but they are not
wrapped in LI 's, ( which do not appear anywhere by the way).
Any idea what i'm doing wrong?
--
Alexandre Plennevaux
LAb[au]
http://www.lab-au.com