bootstrap导航菜单背景切换,用jquery怎么写

bootstrap导航菜单背景切换,用jquery怎么写


米脂
浏览 697回答 2
2回答

精慕HU

不是 Home 的页面,Home 所在的 li 本不应该有 class="active" 的定义,因此也不需要用 jQuery 处理嘛。如果一定要用 jQuery,通常需要给想要设置的 li 加个 id,比如 <li id="nav-home">...</li>,然后可以用 $("#nav-home").removeClass("active") 移除不需要的 class。

慕森王

<style>nav{width: 100%;height: 100px;background: violet;}.one{width: 30px;height: 30px;background: red;}.two{width: 30px;height: 30px;background: orange;}</style></head><body><nav></nav><div class="one"></div><div class="two"></div></body><script type="text/javascript" src="js/jquery-2.1.4.js" ></script><script>$("div").click(function(){var color=$(this).css("background");$("nav").css("background",color)})</script>
打开App,查看更多内容
随时随地看视频慕课网APP