document.getElementById("mydiv").innerHTML="";在IE里面仍然要占位,我要FF的效果。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>div增加内容后,删除内容,怎么IE里面还有原来的位置</title><br />
<style type="text/css">
div{
background-color:#FF0000;
}
</style>
<script type="text/javascript" language="javascript">
function changeDivA(){
document.getElementById("mydiv").innerHTML="加点内容......";
}
function changeDivB(){
document.getElementById("mydiv").innerHTML="";
}
</script>
</head>
<body>
<div id="mydiv"></div>
<form id="form1" name="form1" method="post" action="">
<input type="button" name="button" value="按钮a" onclick="javascript:changeDivA();" />
<input type="button" name="button" value="按钮b" onclick="javascript:changeDivB();" />
</form>
</body>
</html>
以上代码在ie里面执行的效果,FF里面的效果才是我想要的。
但是我这个mydiv仍然要保留。