CSS DOM ?? ????
CSS DOM ?? ???
JS? ???? CSS? ? ??? ?????.
JS? ??? ???? ????? ??? ? ????. ?: imgObj.style.border = “1px solid red”
??? ???? ?? className? ?? ?? ?????. ?: imgObj.className = "imgClass"
style object
? HTML ???? ??? ??? ????. ??? ? ??? ??? ??? ????? ???.
?? ? ??? ??? ??? ?????? ??? ??? ??? CSS? ??? ???? ?????.
??? CSS ?? ??? ??? ?????.
?: imgObj.style.border = "1px solid red";
??? ?? ??? CSS ??? ??
?? , CSS ??? ?? ?? ??? ???? ?????.
??? ?? ?? ?? ? ?? ??? ?? ????? ??, ?? ??? ? ??? ???? ???? ??? ???? ???. ??? ;
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script type="text/javascript"> //網(wǎng)頁加載完成 window.onload = init; function init() { //獲取id=img01的圖片對(duì)象 var imgObj = document.getElementById("img1"); //給<img>標(biāo)記添加行內(nèi)樣式 imgObj.style.width = "400px"; imgObj.style.border = "2px solid red"; imgObj.style.padding = "20px 30px"; imgObj.style.backgroundColor = "#f0f0f0"; } </script> </head> <body > <img id="img1" src="/upload/course/000/000/009/580af7f52278b486.jpg" /> </body> </html>