以下代码如何做到导航菜单点击变颜色,谢谢!不点不变色,点击变色的那种,非常感谢!采纳再追分
<body<?phpbody_class(_hui('layout'));?>><sectionclass="container"><headerclass="heade...
<body <?php body_class( _hui('layout') ); ?>>
<section class="container">
<header class="header">
<?php hui_logo(); ?>
<ul class="nav">
<li class="navto-home"><a <?php if (is_home()) { echo 'class="current"';} ?> href="/"><span class="glyphicon glyphicon-home"></span>首页</a></li>
<li class="navto-tech"><a href="/lyq"><span class="glyphicon glyphicon-phone"></span>连衣裙</a></li>
<li class="navto-life"><a href="/sy"><span class="glyphicon glyphicon-fire"></span>上衣</a></li>
<li class="navto-home"><a href="/ny"><span class="glyphicon glyphicon-gift"></span>内衣</a></li>
<li class="navto-design"><a href="/kz"><span class="glyphicon glyphicon-heart"></span>裤子</a></li>
<li class="navto-design"><a href="/ps"><span class="glyphicon glyphicon-heart"></span>配饰</a></li>
<li class="navto-design"><a href="/xz"><span class="glyphicon glyphicon-cog"></span>鞋子</a></li>
</ul> 展开
<section class="container">
<header class="header">
<?php hui_logo(); ?>
<ul class="nav">
<li class="navto-home"><a <?php if (is_home()) { echo 'class="current"';} ?> href="/"><span class="glyphicon glyphicon-home"></span>首页</a></li>
<li class="navto-tech"><a href="/lyq"><span class="glyphicon glyphicon-phone"></span>连衣裙</a></li>
<li class="navto-life"><a href="/sy"><span class="glyphicon glyphicon-fire"></span>上衣</a></li>
<li class="navto-home"><a href="/ny"><span class="glyphicon glyphicon-gift"></span>内衣</a></li>
<li class="navto-design"><a href="/kz"><span class="glyphicon glyphicon-heart"></span>裤子</a></li>
<li class="navto-design"><a href="/ps"><span class="glyphicon glyphicon-heart"></span>配饰</a></li>
<li class="navto-design"><a href="/xz"><span class="glyphicon glyphicon-cog"></span>鞋子</a></li>
</ul> 展开
2个回答
展开全部
itjob为你解答:
您可以使用javascript来实现,使用监听事件,点击后才反应,变色,举个小例子。
<div id="divs">
<ul id="u">
<li>itjob1</li>
<li>itjob2</li>
<li>itjob3</li>
</ul>
</div>
<script>
var u;
var lis;
window.onload = function(){
u = document.getElementById("u");
lis = u.getElementsByTagName("li");
for(var i=0;i<lis.length;i++){
lis[i].onclick = function(){
//前提是你在设置li的样式的时候要有background-color,不然获取不到backgroundColor
lis[i].style.backgroundColor = 'pink';
}
}
}
</script>
您可以使用javascript来实现,使用监听事件,点击后才反应,变色,举个小例子。
<div id="divs">
<ul id="u">
<li>itjob1</li>
<li>itjob2</li>
<li>itjob3</li>
</ul>
</div>
<script>
var u;
var lis;
window.onload = function(){
u = document.getElementById("u");
lis = u.getElementsByTagName("li");
for(var i=0;i<lis.length;i++){
lis[i].onclick = function(){
//前提是你在设置li的样式的时候要有background-color,不然获取不到backgroundColor
lis[i].style.backgroundColor = 'pink';
}
}
}
</script>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询