HTML ファイルで、DOM 要素を作成しました。
<div id="colorOne"></div>
css ファイルに属性を設定します。
#colorOne{
position: absolute;
top: 70%;
left: 8%;
width: 36px;
height: 36px;
border-color: black;
border-width: 5px;
border-style: solid;
background-color: white;
}
しかし、私が命令するように
$('#colorOne').prop('width'); $('#colorOne').prop('height');
要素の属性を で取得したい場合は、 のみが表示colorOne
されます。しかし、私が変えれば、私が望むものを手に入れることができることにも気付きました.$.prop
undefined
prop
css
そして、私が書くなら
<div id="colorOne" style="width:36px;"></div>
そして$.prop
作品。
それはなぜなのか知りたいです。ブラウザー エンジンは、これら 2 つの異なる書き込み方法をどのように処理しますか?
(1.インラインスタイル 2..cssファイルに属性を設定)