LoginSignup
0
1

More than 3 years have passed since last update.

【JavaScript】イベント全部ログ

Last updated at Posted at 2020-05-25

取り急ぎ
HTMLの各要素の各イベント実行時に開発者ツールのコンソールにログを出力します。
ログが大量に出るのでご注意ください。
ページ解析用

javascript

var logger = function(s){
  return function(){console.log(s);};
};

document.querySelectorAll("*").forEach(function(el){
  var evs = getEventListeners(el);
  for (var k in evs) {
    var name = el.tagName;
    if (el.id) name += "#"+el.id;
    if (el.classList) el.classList.forEach(function(c){
      if (c) name += "."+c;
    });
    el.addEventListener(k, logger(name+"\t"+k.toString()));
  }
});

2020/05/29 修正 タグ名だけじゃ特定しにくそうなのでソース改修。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1