其他分享
首页 > 其他分享> > js 的DOMdocument的使用

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>

标签:DOMdocument,##,age,innerHTML,js,person,使用,var,document
来源: https://www.cnblogs.com/yuanjia8888/p/13959952.html