三.选项卡
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Title</title>
<style type="text/css">
*{margin:0;padding:0;}
body,ul,li,ol,dl,dd,p,h1,h2,h3,h4,h5,h6{ margin:0;}
a{text-decoration:none;}
img{border:none;}
ol,ul{list-style:none;}
body{
width:100%;
background-color:#ffffcc;
background-image:images/1.jpg;
}
#box{
margin:20px 500px;
}
#sidebar_a p{
background:#66ff99;
width:60px;
height:40px;
text-align:center;
border:1px solid #000;
color:#fff;
}
#img{
width:200px;
height:166px;
border:1px solid red;
background:images/g1.jpg;
}
.f_left,.f_right{float:left;}
</style>
</head>
<body>
<div id="box">
<div id="sidebar_a" class="f_left">
<p class="a">a</p>
<p class="b">b</p>
<p class="c">c</p>
<p class="d">d</p>
</div>
<div id="img" class="f_right"></div>
</div>
<script>
var img = document.getElementById("img");//获取切换背景色的标签
var p = document.querySelectorAll("p");//获取侧边栏导航
//console.log(p);
p[0].onmouseover = function(){
img.style.backgroundColor = "#ff66ff";
}
p[1].onmouseover = function(){
img.style.backgroundColor = "#ffcc00";
}
p[2].onmouseover = function(){
img.style.backgroundColor = "#6600cc";
}
p[3].onmouseover = function(){
img.style.backgroundColor = "#33ff00";
}
</script>
</body>
</html>