Adding an element to a node
There is HTML:
<div class="test">
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
And some JS:
$(document).ready(function() {
// do stuff when DOM is ready
$(".test ul").append('<li>Foo</li>');
});
Why doesn't it add anything, but if I remove the html from the append argument string,
.append('Foo')
it works - but that's not the point - the new text is added as an anonymous block, not an li element as I wanted.
Anu suggestions?
edit: Arg, I found the problem. I changed the file saved from Firefox "Save Page", the extension was .xhtml - and here's the problem. I renamed it and it works great.
Thank:)
0
source to share
3 answers