<!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="X-UA-Compatible" content="IE=7"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>visibility与display的差别-www.jb200.com</title>
</head>
<script type="text/
javascript">
function $(id){ return id?document.getElementById(id):''; }
</script>
<body>
<div id="s1" style="width:200px; height:200px; background-color:#f00; float:left;">使用display显示与隐藏!</div>
<div id="s2" style="width:200px; height:200px; background-color:#Aff;float:left;">使用visibility显示与隐藏!</div>
<br/><br/>
<input type="button" onclick="$('s1').style.display = 'none';" value="display隐藏层" /><br/>
<input type="button" onclick="$('s1').style.display = 'block';" value="display显示层" /><br/>
<input type="button" onclick="$('s2').style.visibility = 'hidden';" value="visibility隐藏层" /><br/>
<input type="button" onclick="$('s2').style.visibility = 'visible';" value="visibility显示层" />
</body>
</html>