Reputation: 8360
I'm using prepend() and the result seems to be buggy.
$('#element').prepend('<div><a href="http://google.com"><a href="http://test.com">Test.com</a> - A site</a></div>');
And the html result (also viewed with Firebug) is buggy:
<div>
<a href="http://google.com"></a>
<a href="http://test.com">Test.com</a> - A site
</div>
(The links are just example links)
Upvotes: 2
Views: 347
Reputation: 689
You must write in a proper DOM format. Agreed with Nick Craver.
As soon as "a" tag meet another element "a", DOM automatically closes the previous "a" tag. same as with xml do.
Upvotes: 0
Reputation: 5780
As I know, nested links (the a elements) are not allowed in html. So browser closes first before the second. It has no connection to jQUery.
Upvotes: 1
Reputation: 630509
You can't have an anchor inside an anchor...so it's not "buggy", it's behaving unexpectedly with invalid HTML, but when HTML is invalid that's...well, expected.
Think about it this way, if you clicked on the inside anchor, where should your browser go? You clicked on http://test.com
and http://google.com
.
Upvotes: 5