国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

HTML DOM簡介和新特性

簡介

  • 核心DOM中,提供的屬性和方法,已經(jīng)可以操作網(wǎng)頁了。為什么還要有HTMLDOM呢?

  • 如果在核心DOM中,網(wǎng)頁中節(jié)點層級很深時,訪問這個節(jié)點時將十分麻煩。

  • 那么,HTMLDOM中就提供了通過id直接找節(jié)點的方法,而不用再從HTML根節(jié)點開始。


HTMLDOM的新特性

  • 每一個HTML標(biāo)記,都對應(yīng)一個元素對象。如:<img>對應(yīng)一個圖片對象

  • 每一個HTML標(biāo)記的屬性,與對應(yīng)的元素對象的屬性,一一對應(yīng)。

<!DOCTYPE HTML>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>php.cn</title>
        <script type="text/javascript">
        window.onload = function(){
            //獲取網(wǎng)頁中id=img01的圖片對象
            var imgObj = document.getElementById("img1");
            //修改圖片的屬性的值,圖片標(biāo)記的屬性,元素對象也能用。
            imgObj.src = "/upload/course/000/000/009/580af7f52278b486.jpg";
            imgObj.width = 400;
            imgObj.border = 2;
            imgObj.style = "cursor:pointer";
            imgObj.title = "唯美圖片";
            //核心DOM中的屬性方法,元素對象都能用
            imgObj.parentNode.bgColor = "#f0f0f0";
        }
        </script>
    </head>
    <body >
        <img id="img1" src="/upload/course/000/000/009/580ae23c4a88a881.jpg" />
    </body>
</html>
繼續(xù)學(xué)習(xí)
||
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <script type="text/javascript"> window.onload = function(){ //獲取網(wǎng)頁中id=img01的圖片對象 var imgObj = document.getElementById("img1"); //修改圖片的屬性的值,圖片標(biāo)記的屬性,元素對象也能用。 imgObj.src = "/upload/course/000/000/009/580af7f52278b486.jpg"; imgObj.width = 400; imgObj.border = 2; imgObj.style = "cursor:pointer"; imgObj.title = "唯美圖片"; //核心DOM中的屬性方法,元素對象都能用 imgObj.parentNode.bgColor = "#f0f0f0"; } </script> </head> <body > <img id="img1" src="/upload/course/000/000/009/580ae23c4a88a881.jpg" /> </body> </html>
提交重置代碼