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.
betweet betweetelement.style['property']='value'とelement.style.property='value'javascriptでスタイルを操作するための違いは何ですか?
element.style['property']='value'
element.style.property='value'
この場合には違いがありますが、それは非標準であり、ブラウザーに依存していると思います。Chrome では、ブラケット表記により、キャメルケース バージョンではなく、実際の CSS 名を使用してスタイル プロパティを参照できます。Firefox では機能しません。他のブラウザはテストしていません。
コンソールから、まさにこのページの Chrome で試すことができます。
document.body.style['background-color'] = 'red'