jquery点击按钮显示与隐藏效果
coder_wb 人气:0首先来看实现效果
用jquery来实现这种效果是非常简单的
html
<div class="bottom"> <ul> <li class="active"> <span class="iconfont icon-yemian-copy-copy"></span> <p>首页</p> </li> <li> <span class="iconfont icon-caidan"></span> <p>热卖</p> </li> <li> <span class="iconfont icon-gouwuche"></span> <p>购物车</p> </li> <li> <span class="iconfont icon-my"></span> <p>我的</p> </li> </ul> </div>
css
<style> html, body, div, ul, li, img, p { margin: 0; padding: 0; } body { width: 100%; } ul { list-style: none; } .bottom { border-top: 1px lightgray solid; } .bottom ul { height: 50px; display: flex; justify-content: space-around; align-items: center; } .bottom ul li { text-align: center; } .bottom li span { font-size: 26px; font-weight: bold; } .bottom li p { font-size: 18px; } .bottom li.active { color: crimson; } .bottom li:hover { cursor: pointer; } </style>
js
<script> function tab() { $('.bottom li').on('click', function (e) { $(this).addClass("active").siblings().removeClass("active"); }) } tab(); </script>
记得引用iconfont和jquery
加载全部内容