网页基本结构和获取元素
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> <!--网页的编码--> 5 <meta name="description" content="描述网页的用途"> <!--描述网页内容--> 6 <meta name="keywords" content="测试"> <!--关键字--> 7 <meta name="referrer" content=""> <!--content四个参数 never origin always default--> 8 <meta name="author" content=""> <!--定义网页作者--> 9 <meta http-equiv="refresh" content="30"> <!--定义网页的刷新时间--> 10 11 <title>你好大白</title> <!--标题--> 12 13 <link rel="dns-prefetch" href="https://www.baidu.com"> <!--dns域名解析--> 14 <link rel="stylesheet" type="text/css" href=""> <!--css外部引用--> 15 <base href="" target="_blank"> <!--文档中所有链接标签的默认链接--> 16 </head> 17 <body> 18 19 <div id="target"> 20 这是div区域的内容 21 </div> 22 23 24 25 <script type="text/javascript"> 26 27 28 obj = document.getElementById('target') 29 30 obj.style.backgroundColor = "blue"; //第一种方法将背景颜色改为蓝色的 31 32 obj.style.cssText = "background-color:blue;font-size:13px"; //cssText添加多个属性 33 34 //setAttribute('class','style') 35 obj.setAttribute('style','color:blue'); //用setAtrribute()函数添加属性,第一个参数是类型中的类 36 37 obj.setAttribute('href','css2.css') //href为css地址,后一个参数为css文件名 38 39 40 41 42 </script> 43 44 45 46 </body> 47 </html>
    M54

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号