Javascript 阻止javascript事件冒泡,获取控件ID值
时间:2023-07-02 05:25:57
1. 如何阻止事件冒泡
//非IE
if (event && event.stopPropagation)
event.stopPropagation();
else//IE
window.event.cancelBubble = true;
2.获取控件ID
if (document.all) {
//IE
alert(event.srcElement.tagName+":"+event.srcElement.id);
}
else {
//Firefox
alert(event.target.tagName + ":" + event.target.id);
}
标签:Javascript,事件冒泡,获取控件ID
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python3+pycuda实现执行简单GPU计算任务
2022-06-04 09:55:29
![](https://img.aspxhome.com/file/2023/6/72136_0s.png)
关于Python常用函数中NumPy的使用
2021-09-10 01:00:35
![](https://img.aspxhome.com/file/2023/5/75375_0s.jpg)
python使用xlrd模块读取xlsx文件中的ip方法
2022-12-26 13:42:00
Python脚本实现12306火车票查询系统
2021-07-10 10:05:27
![](https://img.aspxhome.com/file/2023/7/126967_0s.png)
QML使用Python的函数过程解析
2021-12-10 19:20:31
go语言实现markdown解析库的方法示例
2023-06-20 07:37:32
Python实现bilibili时间长度查询的示例代码
2022-11-24 15:52:16
SpringBoot使用flyway初始化数据库
2024-01-28 13:43:38
![](https://img.aspxhome.com/file/2023/1/79271_0s.png)
微信公众平台网页授权获取用户基本信息中授权回调域名设置的变动
2023-11-14 14:01:31
![](https://img.aspxhome.com/file/2023/3/88293_0s.jpg)
灵活调用xsl来解析xml文档(js异步)
2008-09-05 17:12:00
微信小程序之数据缓存的实例详解
2024-04-19 09:49:53
![](https://img.aspxhome.com/file/2023/8/136128_0s.png)
Python学习之字典的创建和使用
2023-12-14 17:43:30
![](https://img.aspxhome.com/file/2023/3/123643_0s.png)
深入解析Python中的集合类型操作符
2022-06-19 01:04:33
MySQL WorkBench管理操作MySQL教程
2024-01-14 10:32:13
![](https://img.aspxhome.com/file/2023/4/103134_0s.png)
opencv实现图像平移效果
2022-09-30 00:22:06
![](https://img.aspxhome.com/file/2023/0/112470_0s.jpg)
教你如何使用firebug调试功能了解javascript闭包和this
2024-04-22 13:09:34
![](https://img.aspxhome.com/file/2023/9/135739_0s.jpg)
MySQL数据库备份过程的注意事项
2024-01-26 23:16:59
![](https://img.aspxhome.com/file/2023/2/121252_0s.png)
SQL Server 2008的一些新特点及独到之处
2009-01-15 12:59:00
Anaconda+VSCode配置tensorflow开发环境的教程详解
2021-04-03 09:47:32
![](https://img.aspxhome.com/file/2023/8/124808_0s.jpg)
浅谈Python浅拷贝、深拷贝及引用机制
2023-01-03 10:28:23
![](https://img.aspxhome.com/file/2023/6/95226_0s.jpg)