Skip to main content

Bug Tracker

Side navigation

#4507 closed bug (invalid)

Opened April 09, 2009 08:32AM UTC

Closed April 10, 2009 11:40PM UTC

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 (0.7 KB) - added by shrimp April 09, 2009 08:33AM UTC.
Change History (1)

Changed April 10, 2009 11:40PM UTC by dmethvin comment:1

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