JavaScript作业----(3)选项卡之鼠标移入切换

三.选项卡

<!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>


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值