console.log(document.getElementsByTagName("body")[0].style.margin) 空 console.log($("body").css("margin")) 8px
走同样的路,发现不同的人生
You can try to get width and the like, and the result will be ''
Because XXX.style.XXX extracts industry attributes
Because what you set through XXX.style.XXX is also an inline attribute, so you can get it this time
Then how to take out the attributes set with css
getComputedStyle(element).margin
The two obtained tags <body> are the same, but the first attribute is overwritten and is empty, and the second one is not overwritten and is 8px.
You can try to get width and the like, and the result will be ''
Because XXX.style.XXX extracts industry attributes
Because what you set through XXX.style.XXX is also an inline attribute, so you can get it this time
Then how to take out the attributes set with css
The two obtained tags <body> are the same, but the first attribute is overwritten and is empty, and the second one is not overwritten and is 8px.