jQuery/Javascript pulling html/innerHTML
<div id="test">
<img align="right" src="images/home-faqs.jpg" alt="FAQS" wi开发者_Python百科dth="428" />
</div>
So I pull #test innerHTML but the result is
<img align="right" src="images/home-faqs.jpg" alt="FAQS" width="428">
it removes the closing slashes, how do I get javascript not to do that?
That is mostly an artifact of the browser and the library. You won't be able to stop that if you are using an an HTML doctype, but it isn't important. The XML-style closing slash is actually not part of the HTML standard. When you're in an XML doctype, javascript will keep the slashes.
Validation only applies to the page as it loads before javascript changes the DOM, so no worries on that front, either.
精彩评论