Bug Tracker

Opened 11 years ago

Closed 11 years ago

#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:
Blocked by: Blocking:

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 (1)

style.html (689 bytes) - added by shrimp 11 years ago.

Download all attachments as: .zip

Change History (2)

Changed 11 years ago by shrimp

Attachment: style.html added

comment:1 Changed 11 years ago by dmethvin

Resolution: invalid
Status: newclosed

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

Note: See TracTickets for help on using tickets.