zoukankan      html  css  js  c++  java
  • js 的DOMdocument的使用

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    </head>
    <body>
    {#<script>#}
    {# var apple;#}
    {# var hh = {firstname:"哇咔咔",lastname:"依",age:"19",eyeColour:"pingk"}#}
    {# document.write(hh.firstname)#}
    {#</script>#}




    {#<script>#}
    {# var person = new Object()#}
    {# person.firstName = "袁冰欣";#}
    {# person.lastName = "杨鹏";#}
    {# person.age = 50;#}
    {# person.eyeColor = "blue";#}
    {# document.write(person.eyeColor)#}
    {#</script>#}

    {#<p id="demo"></p>#}
    {##}
    {#<script>#}
    {# var person = {firstName:"Bill", lastName:"Gates", age:62, eyeColor:"blue"}#}
    {##}
    {# var x = person;#}
    {# x.age = 10;#}
    {##}
    {# document.getElementById("demo").innerHTML = person.firstName + " is " + x.age + " years old.";#}
    {#</script>#}




    {#<p id="demo"></p>#}
    {##}
    {#<script>#}
    {# var txt = "";#}
    {# var person = {fname:"Bill", lname:"Gates", age:62};#}
    {# var x;#}
    {# for (x in person) {#}
    {# document.write(person[x],"<br>")#}
    {# txt += person[x] + " ";#}
    {# }#}
    {# document.getElementById("demo").innerHTML = txt;#}
    {#</script>#}



    {#<p id="demo"></p>#}
    {##}
    {#<script>#}
    {# var person = {#}
    {# firstname:"张依",#}
    {# lastname:"Gates",#}
    {# age:62,#}
    {# eyecolor:"blue"#}
    {# };#}
    {##}
    {#delete person.age;#}
    {# document.getElementById("demo").innerHTML =#}
    {# person.firstname + " is " + person.age + " years old.";#}
    {#</script>#}


    {#<script>#}
    {# var person = {#}
    {# firstName: "张依",#}
    {# lastName : "张坤",#}
    {# id : 648,#}
    {# xx : function (){#}
    {##}
    {# return (person.lastName + " ******* " + this.firstName)#}
    {# }#}
    {# }#}
    {# document.write(person.xx())#}
    {##}
    {#</script>#}

    {#<p id = "p_id"></p>#}
    {##}
    {#<script>#}
    {##}
    {# function HH(a,b){#}
    {# return a + b#}
    {# }#}
    {##}
    {# var x = HH(10,9)#}
    {##}
    {# document.getElementById("p_id").innerHTML = x#}
    {#</script>#}


    {#<p id="demo"></p>#}
    {##}
    {# <script>#}
    {# function myFunction(x, y) {#}
    {# if (y === undefined) {#}
    {# y = 0;#}
    {# }#}
    {# return x * y;#}
    {# }#}
    {# document.getElementById("demo").innerHTML = myFunction(4);#}
    {# </script>#}


    {#<p id="demo"></p>#}
    {##}
    {#<script>#}
    {# var myObject = {#}
    {# firstName:"野",#}
    {# lastName: "林博",#}
    {# fullName: function() {#}
    {# return this.firstName + " " + this.lastName;#}
    {# }#}
    {# }#}
    {# document.getElementById("demo").innerHTML = myObject.fullName();#}
    {#</script>#}



    {#<h1>通过类名查找 HTML 元素</h1>#}
    {##}
    {#<p>Hello World!</p>#}
    {##}
    {#<p class="intro">DOM 很有用。</p>#}
    {##}
    {#<p class="intro">本例演示 <b>getElementsByClassName</b> 方法。</p>#}
    {##}
    {#<p id="demo"></p>#}
    {##}
    {#<script>#}
    {# var x = document.getElementsByClassName("intro");#}
    {# document.getElementById("demo").innerHTML = x[0].innerHTML;#}
    {#</script>#}


    <p>请点击按钮来显示日期</p>
    <button onclick="displayData()">时间是?</button>

    <script>
    function displayData(){
    document.getElementById('demo').innerHTML = Date()
    }
    </script>
    <p id = "demo" ></p>

    </body>

    </html>
  • 相关阅读:
    Windows下Android开发环境搭建
    解决Win7下打开或关闭Windows功能空白一片
    C#中得到程序当前工作目录和执行目录的一些方法
    创业者必看的小故事
    Sql Server 2005外围应用应用配置器打不开了怎么办
    vs2005无法Web调试
    SQL Server 全局变量
    转 document.documentElement与document.body
    [转]使用SSMA将Oracle数据库转成SQL Server 2008
    Delphi 2009、C++Builder2009正式发布
  • 原文地址:https://www.cnblogs.com/yuanjia8888/p/13959952.html
Copyright © 2011-2022 走看看