码迷,mamicode.com
首页 > Web开发 > 详细

js实例4下拉菜单

时间:2016-12-16 22:29:54      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:cti   get   isp   float   element   javascrip   type   elements   cli   

<style type="text/css">
*{ margin:0px auto; padding:0px}
#fenlei{ width:500px; height:35px;}
.xiang{ float:left; width:100px; height:35px; text-align:center; line-height:35px; vertical-align:middle;}
.xiang:hover{ cursor:pointer}
.xuanxiang{ width:500px; height:300px; display:none}
#guonei{ background-color:#63C; display:block}
#guoji{ background-color:#3C9}
#tiyu{ background-color:#C36}
#yule{ background-color:#FF6}
</style>
</head>

<body>

<br />
<div id="fenlei">
<div class="xiang" style="background-color:#63C" onclick="showa(‘guonei‘)">国内新闻</div>
<div class="xiang" style="background-color:#3C9" onclick="showa(‘guoji‘)">国际新闻</div>
<div class="xiang" style="background-color:#C36" onclick="showa(‘tiyu‘)">体育新闻</div>
<div class="xiang" style="background-color:#FF6" onclick="showa(‘yule‘)">娱乐新闻</div>
</div>

<div id="guonei" class="xuanxiang">

</div>

<div id="guoji" class="xuanxiang">

</div>

<div id="tiyu" class="xuanxiang">

</div>

<div id="yule" class="xuanxiang">

</div>


<script type="text/javascript">

function showa(d)
{
var div = document.getElementById(d);

var suoyou = document.getElementsByClassName("xuanxiang");
for(var i=0;i<suoyou.length;i++)
{
suoyou[i].style.display = "none";
}

div.style.display = "block";

}

</script>

<style type="text/css">
*{ margin:0px auto; padding:0px}
#fenlei{ width:500px; height:35px;}
.xiang{ float:left; width:100px; height:35px; text-align:center; line-height:35px; vertical-align:middle;}
.xiang:hover{ cursor:pointer}
.xuanxiang{ width:500px; height:300px; display:none}
#guonei{ background-color:#63C; display:block}
#guoji{ background-color:#3C9}
#tiyu{ background-color:#C36}
#yule{ background-color:#FF6}
</style>
</head>

<body>

<br />
<div id="fenlei">
<div class="xiang" style="background-color:#63C" onclick="showa(‘guonei‘)">国内新闻</div>
<div class="xiang" style="background-color:#3C9" onclick="showa(‘guoji‘)">国际新闻</div>
<div class="xiang" style="background-color:#C36" onclick="showa(‘tiyu‘)">体育新闻</div>
<div class="xiang" style="background-color:#FF6" onclick="showa(‘yule‘)">娱乐新闻</div>
</div>

<div id="guonei" class="xuanxiang">

</div>

<div id="guoji" class="xuanxiang">

</div>

<div id="tiyu" class="xuanxiang">

</div>

<div id="yule" class="xuanxiang">

</div>


<script type="text/javascript">

function showa(d)
{
var div = document.getElementById(d);

var suoyou = document.getElementsByClassName("xuanxiang");
for(var i=0;i<suoyou.length;i++)
{
suoyou[i].style.display = "none";
}

div.style.display = "block";

}

</script>

js实例4下拉菜单

标签:cti   get   isp   float   element   javascrip   type   elements   cli   

原文地址:http://www.cnblogs.com/qdlj/p/6188309.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!