console.log(document.getElementsByTagName("body")[0].style.margin) 空
console.log($("body").css("margin")) 8px
黄舟2017-07-05 10:44:07
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
迷茫2017-07-05 10:44:07
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.