Common selectors, attributes, and methods in JS are called.
Use selector, attribute, and method call together:
<Style> # a {width: 200px; height: 100px; background-color: red ;}. B {width: 200px; height: 100px; background-color: green ;}. div1 {width: 200px; height: 100px; background-color: aqua ;} </style> <body> <div id = "a"> </div> <div class = "B" style = "background-color: black; "> </div> <div class =" B "style =" background-color: chartreuse; "> </div> <div class =" div1 "> elite education </div> <input type =" text "name =" ipt1 "/> <Input type = "checkbox" name = "ckb2"/disabled = "disabled"> </body> <script> // first select the element to add the effect. // ID selector (Use relatively high JS) var a = document. getElementById ("a"); // detection type alert (typeof (document. getElementById ("a"). style. backgroundColor = "royalblue";. innerHTML = "<span> hello <span>";. innerText = "<span> hello <span>"; // class selector var B _class = document. getElementsByClassName ("B"); B _class [0]. style. backgroundColor = "red"; Var B _class = document. getElementsByClassName ("B"); B _class [1]. style. backgroundColor = "blueviolet"; // tag selector var B _ B = document. getElementsByTagName ("div"); B _ B [1]. style. backgroundColor = "yellow"; var div_1 = document. getElementsByName ("ipt1"); div_1 [0]. value = "text box"; var ckb2 = document. getElementsByName ("ckb2") [0]; ckb2.setAttribute ("checked", ""); // remove the ckb2.removeAttribute ("disabled") // create the element var A = document. createElement ("a");. setAttribute ("href", "http://www.baidu.com");. innerText = "Baidu"; document. body. appendChild (a); document. body. removeChild (a); div1.appendChild (a); </script> <body> <! -- DOM Document Object Model BOM Bowers o m --> <div id = "div1" class = "div1"> </div> <div class = "div1"> </div> <input type = "text" name = "ipt1"/> <input type = "checkbox" name = "ckb1" disabled = "disabled"/> </body>
The commonly used selectors, attributes, and method calls in JS are all the content shared by Alibaba Cloud. I hope to give you a reference and support for the customer's house.