HTML——JAVASCRIPT——關燈效果

<!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=utf-8" />
<title>無標題文檔</title>
<style type="text/css">
#b
{
    width:100%;
    height:100%;
    position:fixed;
    top:0px;
    left:0px;
    z-index:1;
    background-color:#333;
    opacity:0.5;-moz-opacity:0.5;filter:alpha(opacity=50);
}
</style>
</head>

<body>
<div id="a" style="z-index:2;position:absolute;height:30px"><input type="button" value="開關" onclick="dianji()"/></div>
<img id="c" src="新建文件夾 (2)/RadArt1_922.jpg"/>
<div id="b" style="display:none"></div>

</body>
<script type="text/javascript">
function dianji()
{
    var s=document.getElementById("b").style.display;
    if(s=="block")
    {
        document.getElementById("b").style.display="none";    
    }    
    else
    {
        document.getElementById("b").style.display="block";    
    }
}

</script>
</html>
相關文章
相關標籤/搜索