Ticket #4507 (closed bug: invalid)
problem on html() in IE
| Reported by: | shrimp | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | unfiled | Version: | 1.3.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
the html() function return a wrong content, it help me add some unwant "<p>" tag (can see belows example code)
the alert for IE will be "<p>show<span id=hidden><div>this is a div</div>this is a testing</span><p></p>"
an unwanted <p> added before the </p>
but it works great at firefox
example code:
<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 StrictEN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html>
<head>
<title>testing</title> <script src="./script/jquery-1.3.2.min.js" type="text/javascript"></script> <script language="javascript">
$(document).ready(function(){
var content = $("div.test-body").html();
alert(content); $("div.test-body").html(content);
})
</script>
<style type="text/css">
#hidden {
display:none;
}
</style>
</head>
<body>
<div class='test-body'>
<p>show<span id="hidden"><div>this is a DIV</div>this is a testing</span></p>
</div>
</body>
</html>
Attachments
Change History
comment:1 Changed 4 years ago by dmethvin
- Status changed from new to closed
- Resolution set to invalid
IE does not understand XHTML, and will treat your document using HTML4 rules. In HTML4, the <p> element cannot contain other block-level elements such as <div>, so your markup is invalid as far as IE is concerned.
http://blogs.msdn.com/ie/archive/2005/09/15/467901.aspx http://www.w3.org/TR/html4/struct/text.html#h-9.3.1
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

