The example in this article describes the js method of obtaining the external link style of an element. Share it with everyone for your reference. The specific analysis is as follows:
Generally set inline styles for elements, such as
. If you want to get its style, you can get or set document.getElementById("div1").style.width. However, if the style is in an external link or a non-inline style of the page, it cannot be obtained.In standard browsers, you can get the external link style through window.getComputedStyll(obj,null)[property], but in IE browser, you can get it through obj.currentStyle.
The complete html code is as follows:
If you click on me, the width pops up.
Click me to pop up the width.
Also click on me~O(∩_∩)O~.
I hope this article will be helpful to everyone’s JavaScript programming design.