jQuery insert link
<p>Trying to append some text in jQuery to convert it into a link for a tree style file browser.</p>

<p>jQuery:</p>

<pre><code>  $(document).ready(function()
{
    var listView = $('div.tree ul');

    $('div.tree &gt; ul &gt; li').each(
        function() {
            var newLink = document.createElement('a');
            $('div.panel').append(newLink);
            newLink.html($(this).children('span.cat').text());
            $(newLink).click(function(e)
            {
                alert($('div.tree span.cat:contains("'+$(this).text()+'")'));
                e.preventDefault();
            });
        }
    );
});
</code></pre>

<p>The content is dynamically generated by PHP , but follow  this kind of structure:</p>

<pre><code>&lt;div class="tree"&gt;
   &lt;ul&gt;
      &lt;li&gt;
          &lt;span class="cat"&gt;Category &lt;/span&gt;
      &lt;ul&gt;
          &lt;li&gt;
              &lt;a href="example.jpg"&gt;example.jpg&lt;/a&gt;
          &lt;/li&gt;


 ///////////////etc////////
</code></pre>

<p>This gives error <code>"NewLink is not a function"</code></p>
