封装获取dom元素的简单实例
作者:jingxian 时间:2024-04-17 09:57:25
示例如下:
<script>
//函数: 反复执行的代码块
//全局只有一个对象,防止全局变量污染
var itcast = {
getElen : {
tag : function(tag){
return document.getElementsByTagName(tag);
},
id : function(id){
return document.getElementById(id);
}
},
css : {
addStyle : function(){},
removeStyle : function(){},
addClass : function(){}
}
}
//调用
itcast.getElen.tag('body')[0];
</script>
标签:dom,元素
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
JavaScript Table行定位效果
2009-05-25 10:47:00
javascript让浏览器实现复读机的功能
2008-10-10 11:49:00
Python+OpenCV实现分水岭分割算法的示例代码
2021-01-11 05:01:38
![](https://img.aspxhome.com/file/2023/7/100827_0s.jpg)
利用pandas合并多个excel的方法示例
2021-05-28 00:02:00
![](https://img.aspxhome.com/file/2023/0/86410_0s.png)
详解Python垃圾回收机制和常量池的验证
2022-12-28 09:58:29
关于Python中request发送post请求传递json参数的问题
2022-12-23 06:20:33
![](https://img.aspxhome.com/file/2023/8/104398_0s.png)
Python日期时间对象转换为字符串的实例
2022-05-24 14:51:29
Jupyter notebook 远程配置及SSL加密教程
2021-06-24 07:15:06
![](https://img.aspxhome.com/file/2023/5/115175_0s.jpg)
python 数据类(dataclass)的具体使用
2022-11-08 09:36:27
Python内置函数property()如何使用
2022-12-07 07:04:28
说说回车键触发表单提交的问题
2009-02-03 13:25:00
js版sliderBar(滑动条)控件
2008-10-18 15:59:00
将pymysql获取到的数据类型是tuple转化为pandas方式
2024-01-26 11:26:18
Python基于Django实现验证码登录功能
2023-06-25 03:21:13
![](https://img.aspxhome.com/file/2023/8/72238_0s.png)
利用vue+elementUI实现部分引入组件的方法详解
2023-07-02 16:33:51
总结用Pdb库调试Python的方式及常用的命令
2023-03-11 02:09:53
仿淘宝星级评分效果
2010-09-03 18:37:00
python实现的重启关机程序实例
2023-08-09 22:54:20
python进行TCP端口扫描的实现
2021-04-18 12:33:32
python 3.3 下载固定链接文件并保存的方法
2023-09-22 16:43:50