调试js事件小技巧
发表于|更新于
|浏览量:
万人都要将火熄灭,我一人独将此火高高举起。——海子
分享一个js调试事件小技巧
1 | <!DOCTYPE html> |
这里一个按钮,啥都没有
我们运行一下,给它在chrome console里添加事监听
1 | // 先用选中元素光标选一下按钮,这样$0就会指向按钮 |

这时候我们触发其任何事件都会有输出

针对某一事件的话就传入该事件
1 | monitorEvents($0, ["click"]) |

相关推荐
2021-12-01
nvue中tap事件取消冒泡
青春是一种持续的陶醉,是理智的狂热。——拉罗什富科 nvue中@tap.stop阻止冒泡失效了 代码如下: 1<view @tap="parentEvent"><view @tap.stop="childEvent">触发触发</view></view> 大概有两种方案,第一种是改事件,改为@touchend事件 1<view @tap="parentEvent"><view @touchend="childEvent">触发触发</view></view> 不过还有另一种方式 1234567parentEvent(e) { console.log('parentEvent');},childEvent(e) { console.log('childEvent'); e.stopPropagation();}
2022-06-06
TailwindCss
懒惰象生锈一样,比操劳更能消耗身体;经常用的钥匙,总是亮闪闪的。——富兰克林 分享一个CSS框架,内置了很多css样式: https://www.tailwindcss.cn/ 使用方式: https://www.tailwindcss.cn/docs/installation 注意其不支持IE浏览器 仓库地址:https://github.com/tailwindlabs/tailwindcss 甚至你可以直接在Playground中进行尝试: https://play.tailwindcss.com/
2020-10-21
页面点击随机字符
不要让昨天占用今天的时间。 ——美洲 应群友的要求分享给大家~ 123456789101112131415161718192021222324252627282930313233343536//随机字$(function () { var a_idx = 0, b_idx = 0; c_idx = 0; jQuery(document).ready(function ($) { $("body").click(function (e) { var a = new Array("Daphne", "Ficus", "Iris", "Maackia", "Lythrum", "Myrica", "Sabia", "Flos", "あなたのことが好きです", "嬉しい", "頑張って!"...
2023-01-14
google、YouTube、Medium进度条
当一个男人偷走了你的妻子时,最好的报复是让他去赡养她——吉特里 这是一个目前25K stars的项目 github:https://github.com/rstacruz/nprogress 演示网址:http://ricostacruz.com/nprogress 进度条是浏览器上方的这个
2022-07-01
js让光标选择节点中部分文本
我走得很慢,但我从不后退。——林肯 如题,代码: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152<!DOCTYPE html><html><head> <meta charset="utf-8"> <title></title></head><body> <div id="container">ruben</div> <button>r</button> <button>u</button> <button>b</button> <button>e</button> <button>n</button> &...
2023-06-05
js获取当前浏览器是否采用深色主题
荣誉在于劳动的双手。——达芬奇 代码如下: 1window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches 对应的mdn: https://developer.mozilla.org/zh-CN/docs/Web/API/Window/matchMedia
