js 层的显示和隐藏
<!DOCTYPE html>
<html lang=”en” xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta charset=”utf-8″ />
<title></title>
<style>
#dv {
width:100px;
height:100px;
border:1px solid red;
}
</style>
<script>
onload = function () {
document.getElementById(\’btnShow\’).onclick = function () {
var dv = document.getElementById(\’dv\’);
if (this.value == \’隐藏\’) {
this.value = \’显示\’;
dv.style.display = \’none\’;
} else {
this.value = \’隐藏\’;
dv.style.display = \’block\’;
}
}
}
</script>
</head>
<body>
<input type=”button” name=”name” value=”隐藏” id=”btnShow”/>
<div id=”dv”>
123
</div>
</body>
</html>