網(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)推薦
- 2022-10-16 Pytorch?linear?多維輸入的參數(shù)問題_python
- 2022-09-25 spring如何解決循環(huán)依賴
- 2023-05-23 golang中的單引號轉(zhuǎn)義問題_Golang
- 2022-11-04 Android自定義View實現(xiàn)時鐘功能_Android
- 2023-02-02 一文帶你深入了解C++中的類型轉(zhuǎn)換_C 語言
- 2022-05-18 python基礎(chǔ)教程之csv格式文件的寫入與讀取_python
- 2022-06-02 GO中?分組聲明與array,?slice,?map函數(shù)_Golang
- 2022-11-29 Mybatis中如何傳入map參數(shù)呢?
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)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之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- 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被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支