For example, $('#some-div').load('http://foo.bar #content')
will retrieve #content
from http://foo.bar but with all HTML <!--开发者_JS百科comments-->
stripped.
How can I retrieve the contents of #content
including any comments?
From the jQuery manual:
jQuery uses the browser's
.innerHTML
property to parse the retrieved document and insert it into the current document. During this process, browsers often filter elements from the document such as<html>
,<title>
, or<head>
elements. As a result, the elements retrieved by.load()
may not be exactly the same as if the document were retrieved directly by the browser.
So you should use $.get()
to retrieve the HTML instead of $.fn.load()
精彩评论