在线
客服

发布
需求

天盟
APP

天盟APP下载

关注
微信

微信扫一扫访问
顶部

用JS怎么实现菜单栏鼠标移入时背景色、字体颜色改变(在下面的代码中修改)

多级菜单 JSul {list-style: none;}.top-nav{font-size: 12px;font-weight: 700;}.top-nav li {float: left;margin-right: 1px;}.top-nav li a {display: block;width: 80px;line-height: 20px;text-decoration: none;background: #ddd;color: #666;text-align: center;}.top-nav li ul {display: none;padding: 0;position: relative;  width: 80px;}.top-nav li ul li ul {position: absolute;  top: 0;left: 81px;   }.top-nav li a:hover {background: #900;color: white;    }  <script>window.onload=function(){var Lis=document.getElementsByTagName("li");for(var i=0;i

免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。

版权声明:作者保留权利,不代表天盟立场。

使用道具 举报

全部参与2

如果用原生的话,可以使用原生的事件委托,在父级上添加事件,当事件触发的元素是你想要的元素的话改变颜色。

使用道具 举报

js就是用onmouseover和onmouseout事件来操作:




Document

#test{width:100px;height:50px;background:red;color: white;font-size:24px;text-align:center;line-height:50px;}



js方法




在事件里面写入你要修改的属性就行!!!

使用道具 举报

发新帖
国内首家创新型IT技术需求众包服务平台,软件需求就上天盟网! 立即登录 立即注册