Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
JavaScript で現在のページを検出する方法はありますか?
私が知りたいのは、現在のページを検出し、それに応じて要素のスタイルを設定できるようにするためです。
ページの URL を取得する
location.href
または
document.URL
ID で要素にスタイルを設定します。
document.getElementById('mydiv').style.border = '1px solid black';