1.隐藏层
<script type="text/javascript">
function toggleDiv(cd) {var div1 = document.getElementById("div1");
if (cd.checked) {
div1.style.display = '';
}
else { div1.style.display = "none"; }
}
</script>
</head>
<body>
<input type="checkbox" id="onShow" οnchange="toggleDiv(this)" /><label for="onShow">显示高级选项</label>
<div id="div1" style="display:none">这里是一些高级选项</div>
2.鼠标滑过显示 移开不显示
<a href="http://vip.book.sina.com.cn/book/index_196513.html" οnmοuseοut="document.getElementById('changShou').style.display='none'" οnmοuseοver="document.getElementById('changShou').style.display=''">120工程</a>
<div id="changShou">长寿120工程</div>
IE中body的事件范围:在body中内容有效,如果想要整个有效 需要在document中做
元素的位置、大小单位
练习 宽度加10
function incWidth(){
var oldwidth=document.getElementById('div1').style.width;
oldwidth=parseInt(oldwidth,10);
oldwidth+=50;
oldwidth=oldwidth+"px";
document.getElementById('div1').style.width=oldwidth;
}
层的操作 absolute
练习:图片跟随鼠标onmousemove
傻瓜的天才