JS 简单展开关闭切换代码
时间:2024-05-05 09:14:30
第一种方法:原理比较简单通过判断当前是隐藏还是显示的,并以此来判断。
<script language="javascript"> function show() { var a=document.getElementById('aa'); a.style.display=="none"?a.style.display="":a.style.display="none"; } </script> 操作 <div id="aa" style="display:">脚本之家 欢迎你</div>
第二种:更简单,但原理不是一眼能看出来
能详解的朋友可以留言啊,我们给补充上
<script language="javascript"> function show(){ with(document.getElementById('aa').style){display==""&&(display="none")||(display="")} } </script> 操作 <div id="aa" style="display:">jb51.net 欢迎你</div>
标签:JS,展开,关闭
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
go select编译期的优化处理逻辑使用场景分析
2024-05-25 15:16:43
python2.7 安装pip的方法步骤(管用)
2022-02-11 06:28:43
![](https://img.aspxhome.com/file/2023/0/72920_0s.png)
keras读取h5文件load_weights、load代码操作
2023-05-21 18:00:22
![](https://img.aspxhome.com/file/2023/2/117392_0s.jpg)
详解python项目实战:模拟登陆CSDN
2023-02-09 01:53:34
![](https://img.aspxhome.com/file/2023/1/113121_0s.png)
ASP.NET(C#)中操作SQLite数据库实例
2024-01-20 08:30:12
![](https://img.aspxhome.com/file/2023/0/87170_0s.jpg)
在Python的web框架中配置app的教程
2023-03-28 12:12:17
MySQL 请选择合适的列
2024-01-23 05:33:31
![](https://img.aspxhome.com/file/2023/2/111402_0s.png)
给大家整理了19个pythonic的编程习惯(小结)
2024-01-02 08:00:05
在ASP.NET 2.0中操作数据之三十:格式化DataList和Repeater的数据
2023-07-22 20:15:21
![](https://img.aspxhome.com/file/2023/9/76339_0s.png)
.Net行为型设计模式之迭代器模式(Iterator)
2024-06-05 09:27:47
![](https://img.aspxhome.com/file/2023/5/122815_0s.png)
盘点Python 爬虫中的常见加密算法
2023-07-19 05:05:22
![](https://img.aspxhome.com/file/2023/5/124245_0s.jpg)
MySQL与PHP的基础与应用专题之数据控制
2023-11-23 01:03:21
![](https://img.aspxhome.com/file/2023/8/99348_0s.png)
Python开发中爬虫使用代理proxy抓取网页的方法示例
2023-02-04 08:56:06
对python mayavi三维绘图的实现详解
2022-04-29 03:17:50
![](https://img.aspxhome.com/file/2023/0/135000_0s.jpg)
简单解决Windows中MySQL的中文乱码与服务启动问题
2024-01-21 00:58:43
![](https://img.aspxhome.com/file/2023/8/124068_0s.jpg)
vscode使用chatGPT 的方法
2022-10-10 15:55:38
![](https://img.aspxhome.com/file/2023/8/104958_0s.png)
Microsoft VBScript 运行时错误 错误800a0005 无效的过程调用或参数
2010-03-25 21:51:00
Golang利用channel协调协程的方法详解
2024-05-08 10:21:54
apache+mysql+php+ssl服务器之完全安装攻略
2023-11-16 07:34:16
javascript中注册和移除事件的4种方式
2024-04-22 12:49:02