Warrior Warrior - 5 months ago 13
Javascript Question

Javascript - innerHTML function in IE

I have a html file with content

<html>
<body>
<script language="JavaScript">
function fun1()
{
alert(document.getElementById('id1').innerHTML);
}
</script>
<div id="id1">
<ul>
<li>Here111</li>
<li>Here222</li>
<li>Here333</li>
</ul>
</div>
<a href="javascript:void(0)" onclick="fun1()">Click</a>
</body>
</html>


In innerHTML function iam getting only

<ul>
<li>Here111
<li>Here222
<li>Here333</li>
</ul>


The
</li>
tag is missing how can I get entire content?

Answer

Add <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> in the beginning of html

Comments