The 'name' property for anchors has been deprecated in XHTML, use IDs
instead (or no identifier at all):

<div id="sub-navigation">
<ul>
    <li><a id="thing" href="thing.html">thing</a></li>
    <li><a id="otherthing" href="otherthing.html">other thing</a></li>
</ul>
</div>

$('#sub-navigation > ul > li').each(function(i){
    var subs = '<li><a href="xisbacon.htm">'+i+' - Xis bacon</a></
li>';
    subs += '<li><a href="xisgalinha.htm">'+i+' - Xis galinha</a></
li>';
    $('<ul/>')
        .append(subs).appendTo(this);
});

On Jan 21, 10:58 am, Frederic <m...@frederic-hemberger.de> wrote:
> Hi,
>
> after fiddeling around to find a solutions for some hours now, maybe
> you can give me a hint:
>
> I have a navigation like this:
> <div id="sub-navigation">
> <ul>
>         <li><a name="0" href="page.html">page name</a></li>
>         ... insert nodes with jQuery here ...
> </ul>
> </div>
>
> I want to insert nodes dynamically with jQuery and the final structure
> should look like this:
> <div id="sub-navigation">
> <ul>
>         <li><a name="0" href="page.html">page name</a></li>
>         ...
>         <li>
>                 <a ...>...</a>
>                 <ul>
>                         <li><a ...>...</a></li>
>                 </ul>
>         </li>
>         ...
> </ul>
> </div>
>
> As I want to attach a click function to each link element, I started
> like this:
> for (var i=0;i<nav.length;i++)
> {
>         var navEntry = $('<a href="#">' + nav[i].name + '</a>')
>                 .click( function() {
>                         ...
>                 }).appendTo('#sub-navigation ul');
>
>         for (var j=0;j<subnav.length;j++)
>         {
>
>                 $('<a href="#">' + subnav[j].number + ' ' + subnav[j].name + 
> '</a>')
>                 .wrapInner('<li></li>')
>                 .appendTo(navEntry);
>         }
>
> }
>
> But how do I get the correct nesting for the navigation structure
> above?

Reply via email to