Ctrl+/
IE11
F11
ESC
PgUp
PgDn
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS封装透明度</title>
</head>
<style>
#test1{width:250px;height:250px;text-align:center;background-color:#930;margin:0 auto;color:#F00;}
#test2{width:250px;height:250px;text-align:center;background-color:blue;margin:0 auto;color:#f00;}
</style>
<body bgcolor="#eee">
<div id="test1">我是模块1</div>
<div id="test2">我是模块2</div>
<script>
/* 封装setOpacity函数
* node 类名 level 透明度 */
function setOpacity(node,level){
node = typeof node=="string" ? document.getElementById(node) : node;
if(document.all){ //document.all 是IE支持属性 firefox 不支持
node.style.filter = 'alpha(opacity=' + level+ ')';
}else{
node.style.opacity= level/100;
}
/* 调用函数 */
setOpacity("test1",20);
setOpacity("test2",20);
</script>
</body>
</html>
CSS代码...
JS代码...
xxxxxxxxxx