for example have a div,html code below
<div id="testDiv"></div>
but when i set the innerHTML property of the div(id=testDiv) on ie ,see the code below:
document.getElementById('testDiv').innerHTML= '';
and the div will have a height and width,not a blank div any more
so that is why??
if i want the div is a blank div when set the innerHTML=”(if do not set the display:none),how should i do?
now show the test code(different results runing on ie7 and chrome)
<!DOCTYPE>
<html>
<head>
<style>
#bl{background:red;}
</style>
<script type="text/javascript">
function f(a){
var t=document.getElementById("bl");
t.innerHTML=a;
}
</script>
</head>
<body>
<button type="button" onclick="f('')">test</button>
<div id="bl"></div>
</body>
</html>
I think this is a known IE behaviour.
In addition to setting
innerHTMLto empty string you can also setfont-sizeto 0.