The problem of setting style attribute of dom Node

I did an experiment today

node.style ["margin-left"] =" 100px"

this code successfully sets the css property

but when I output node.style in the console, I don"t find the attribute margin-left. I just see

.

clipboard.png

marginLeft

clipboard.png

visit node.style ["margin-left"] again and you will get 100px

.

question:

  • Why there is no margin-left property in the object and its prototype, but I only set style.marginLeft , access margin-left still has a value and change one side and the other will change
Mar.14,2021
The properties of

css can be accessed through camelCase in the style object of js. The advantage of this is that you can use .margin left or ["marginLeft"]. In fact, you can also access it in the form of a trumpet, but you cannot use .margin-left (js syntax does not allow it), but you can use ["margin"] to access it. The two kinds of access in the dom object are equivalent, so the two properties are also modified by Synchronize.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30b29-2b588.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30b29-2b588.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?