dom学习(一)

    技术2022-05-11  86

    <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > < html > < head > < title > Dom Example </ title > < meta  name ="GENERATOR"  content ="Microsoft Visual Studio .NET 7.1" > < meta  name =ProgId  content =VisualStudio.HTML > < meta  name =Originator  content ="Microsoft Visual Studio .NET 7.1" > < script  language =javascript >      function  html()    {         var  oHtml = document.documentElement;        alert(oHtml.innerText + "    " + oHtml.childNodes.length);        alert(oHtml.innerHTML);    }     function  fist()    {         var  oHtml = document.documentElement;                 var  oHead = oHtml.firstChild;        alert( " innerText: " + oHead.innerText);        alert( " innerHTML: " + oHead.innerHTML);            }     function  lastNode()    {         var  oHtml = document.documentElement;         var  oBody = oHtml.lastChild;                alert( " innerText: " + oBody.innerText);        alert( " innerHTML: " + oBody.innerHTML);    }             function  html2()    {         var  oHtml = document.documentElement;        alert(oHtml.outerText + "    " + oHtml.childNodes.length);        alert(oHtml.outerHTML);    }     function  fist2()    {         var  oHtml = document.documentElement;                 var  oHead = oHtml.firstChild;        alert( " outerText: " + oHead.outerText);        alert( " outerHTML: " + oHead.outerHTML);            }     function  lastNode2()    {         var  oHtml = document.documentElement;         var  oBody = oHtml.lastChild;                alert( " outerrText: " + oBody.outerText);        alert( " outerHTML: " + oBody.outerHTML);    }         </ script > </ head > < body > < id =1 > hello world! </ p > < > Isn't this exciting? </ p > < > You'are learning to user the dom </ p > < a > innerText & innerHtml: </ a >< br > < input  type =button  name =bt1  value =fistNode  onclick ="html()" /> < input  type =button  name =bt2  value =fistNode  onclick ="fist()" /> < input  type =button  name =bt3  value =lastNode  onclick ="lastNode()" /> < br > < a > outerText & outerHtml: </ a >< br > < input  type =button  name =bt4  value =fistNode  onclick ="html2()"   /> < input  type =button  name =bt5  value =fistNode  onclick ="fist2()"   /> < input  type =button  name =bt6  value =lastNode  onclick ="lastNode2()" /> < br > </ body > </ html >  

    最新回复(0)