Record the Javascript access style sheet
Javascript can access the style attributes of elements in a webpage, for example:
<Div id = "Main" style = "background-color: Red"> </div>
Access style attributes through JS
Alert (document. getelementbyid ("Main"). style. backgroundcolor );
Modifying style attributes through JS
Document. getelementbyid ("Main"). style. backgroundcolor = "blue ";
AboveCodeWe are familiar with it, but we usually use style sheets to control the appearance attributes of elements, for example:<Meta http-equiv = "Content-Type" C> <br/> <style type = "text/CSS"> # Main {margin-left: 200px; margin-top: 70px; width: 200px; Height: 100px; background-color999999; Border: 1px solid #666666 ;} </style> show <p> <input type = "button" value = "Get style"> <input type = "button" value = "Write style"> <input type = ""button" value = "get final style">