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

HTML DOM method of accessing HTML elements

getElementById()

  • Function: Find the element object with the specified id in the web page.

  • Syntax: var obj = document.getElementById(id)

  • Parameters: id refers to the value of the id attribute marked in the web page.

  • Return value: Returns an element object.

  • Example: var imgObj = document.getElementById(“img01”)


getElementsByTagName(tagName)

  • ##Function: Find the specified HTML tag and return an array.

  • Syntax: var arrObj = parentNode.getElementsByTagName(tagName)

  • Parameters: tagName is the tag name to be found, without angle brackets.

  • Return value: Returns an array. If there is only one node, an array is also returned.

  • Example: var arrObj = ulObj.getElementsByTagName(“l(fā)i”)

  • <!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(){
                //獲取id=ulTag的網(wǎng)頁(yè)對(duì)象
                var ulObj = document.getElementById("question");
                //查找<ul>下的所有的<li>標(biāo)記
                var arrObj = ulObj.getElementsByTagName("li");
                //給所有的<li>標(biāo)記增加CSS效果
                for(var i=0;i<arrObj.length;i++)
                {
                    //給每個(gè)<li>標(biāo)記加style屬性
                    arrObj[i].style = "color:blue;font-size:24px;";
                }
            }
            </script>
        </head>
        <body >
            <ul id="question">
                <li>mac 中系統(tǒng)自帶的apache 誤刪了怎么恢復(fù)</li>
                <li>CURL POST數(shù)據(jù)量過大,接收不到服務(wù)端的信息</li>
                <li>用了構(gòu)造函數(shù)為什么這個(gè)還是2?</li>
                <li>cookies登錄原理</li>
            </ul>
    </html>
Continuing Learning
||
<!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(){ //獲取id=ulTag的網(wǎng)頁(yè)對(duì)象 var ulObj = document.getElementById("question"); //查找<ul>下的所有的<li>標(biāo)記 var arrObj = ulObj.getElementsByTagName("li"); //給所有的<li>標(biāo)記增加CSS效果 for(var i=0;i<arrObj.length;i++) { //給每個(gè)<li>標(biāo)記加style屬性 arrObj[i].style = "color:blue;font-size:24px;"; } } </script> </head> <body > <ul id="question"> <li>mac 中系統(tǒng)自帶的apache 誤刪了怎么恢復(fù)</li> <li>CURL POST數(shù)據(jù)量過大,接收不到服務(wù)端的信息</li> <li>用了構(gòu)造函數(shù)為什么這個(gè)還是2?</li> <li>cookies登錄原理</li> </ul> </html>
submitReset Code