LoginSignup
1
0

More than 5 years have passed since last update.

ブラウザのデベロッパーツールみたいにDOMElementのシンボル名を取得したい

Last updated at Posted at 2018-02-28

image.png

こういう<tagName>["#"+id][["."+className][...]]のようなシンボル名を取得するにはどうしたらいいのか?
結局ググってもわかりませんでした。

デバッグ用シンボルID取得関数
function debug_getSymID(obj) {
    if(obj instanceof HTMLElement){
        return obj.tagName.toLowerCase()
        +(obj.id ? "#"+obj.id : "")
        +(obj.className ? obj.className.replace(/^|\s+/g, ".") : "")
    }
    return typeof obj
}

うーん。こんな方法で作るしか無いのかな

追記:
@hoo-chan様 ソースコードについての修正依頼ありがとうございます!

1
0
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
1
0