網(wǎng)站首頁 編程語言 正文
本文實例為大家分享了jquery實現(xiàn)點擊按鈕顯示與隱藏的具體代碼,供大家參考,具體內(nèi)容如下
首先來看實現(xiàn)效果
用jquery來實現(xiàn)這種效果是非常簡單的
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
原文鏈接:https://blog.csdn.net/WU567_/article/details/107029251
相關(guān)推薦
- 2023-02-15 Python?PyWebIO提升團隊效率使用介紹_python
- 2022-09-15 python基于tkinter圖形化編程實現(xiàn)簡易計算器功能_python
- 2022-04-14 如何解決error: failed to push some refs to ‘xxx(遠程庫)‘
- 2022-09-19 Android簡單實現(xiàn)菜單拖拽排序的功能_Android
- 2022-10-25 Python中random函數(shù)的用法整理大全_python
- 2022-04-17 WPF框架Prism中導(dǎo)航Navigation用法介紹_基礎(chǔ)應(yīng)用
- 2022-12-29 Kotlin?Service服務(wù)組件開發(fā)詳解_Android
- 2022-11-17 Android文本與視圖基本操作梳理介紹_Android
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支