数字で始まる id 属性は(正当な HTML だが)CSS セレクターとしては不正なので、単純に # をつけるだけだと document.querySelector で取得できない。`[id='${id}']` や `#${CSS.escape(id)}` にする必要がある

jay-esjay-es のブックマーク 2024/01/20 10:47

その他

このブックマークにはスターがありません。
最初のスターをつけてみよう!

Difference between getElementByID and querySelector

    Assume you have a valid HTML element in DOM. I assumed the following snippets to be the same. let id = "037e3778-e157-4715-bff5-e466230fe7a3" const byId = document.getElementById(id) console.log(by...

    \ コメントが サクサク読める アプリです /

    • App Storeからダウンロード
    • Google Playで手に入れよう