js adds multiple styles to elements, and the browser is fully compatible with the example writing method:
<a href="javascript:;" id="test" style="font-size:25px;background:#080;">Test3</a><script>var obj=document.getElementById("test");var oldStyle=obj.style.cssText;alert(oldStyle);obj.style.cssText="border:2px red solid;color:#f00;"+oldStyle;</script>js adds multiple styles to elements. The fastest and most convenient way is to use the cssText attribute, but it will rewrite the original value of the entire style. It is very simple. Just like in the previous example, you can record the original original value of the original style with a variable and then splice a string.
But one thing to note is that the last style value returned by ie8 and the following browsers obj.style.cssText is without a semicolon, such as: font-size:25px;background:#080. I just want to say that ie is as unhappy as ever, haha.
Therefore, in the example, the oldStyle is deliberately placed behind the string splicing. In this way, even if the last style value of the spliced style string does not have a semicolon, there will be no problem. The display of each browser style application is consistent. This is also a small trick. It has no technical content, but it is easy to ignore or forget. If you know that you have a bad memory, Mark ^_^