I have previously answered this question, but I do not fully understand why the answer is correct. The gist of the answer:
<p id="jqrender"></p> $(function() { $('#jqrender').html("<a href=http://www.website.com/>foo bar</a>"); });
On latest Chrome on OSX, jQuery interprets this as <a href="website.com"></a>foo bar
. Which makes sense, I guess, because it thinks the closest markup correction is <a href="website" />
. But natively, Chrome itself will interpret the markup as <a href="website.com/">foo bar</a>
.
Why is this? I would like a technical answer, what part of jQuery is doing this markup-fixing, what are some general rules it follows, and how can I guess how jQuery will react to other broken markup?