试图在jQuery中追加一些文本,将其转换为树型文件浏览器的链接。jQuery插入链接
的jQuery:
$(document).ready(function()
{
var listView = $('div.tree ul');
$('div.tree > ul > 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();
});
}
);
});
的内容是动态的PHP生成的,而是遵循这种结构:
<div class="tree">
<ul>
<li>
<span class="cat">Category </span>
<ul>
<li>
<a href="example.jpg">example.jpg</a>
</li>
///////////////etc////////
这给了错误"NewLink is not a function"
这就是它的欢呼声。 – BobFlemming