In general, this format is used to set the style of element objects using js.
The Code is as follows:
Var element = document. getElementById ("id ");
Element. style. width = "20px ";
Element. style. height = "20px ";
Element. style. border = "solid 1px red ";
There are a lot of styles, and there are a lot of code. It is a typical process of destroying the original styles and recreating objects through JS, will increase the browser overhead.
Js has a cssText method:
Syntax: obj.style.css Text = "style ";
The above code can be modified to: Thanks to sliuqin for its correction in the message.
Element.style.css Text ("width: 20px; height: 20px; border: solid 1px red ;")
Which of the following is true?
The Code is as follows:
Element.style.css Text = "width: 20px; height: 20px; border: solid 1px red ;";
In this way, you can try to avoid page reflow and improve page performance.