Home
Web Front-end
JS Tutorial
JS uses the getComputedStyle() method to obtain CSS attribute values_javascript tips



JS uses the getComputedStyle() method to obtain CSS attribute values_javascript tips
In the process of debugging web pages, js is often used to obtain the CSS style of elements. There are many methods. Now I only summarize the methods I often use as follows:
1. obj.style: This The method is that JS can only get the value written in the style attribute written in the html tag (style="..."), but cannot get the attribute defined in
JS gets CSS attribute value
< script type=”text/javascript”>
alert(document.getElementById(“css88″).style.width);//200px
alert(document.getElementById(“css88″).style.color) ;//Blank