7_JavaScript_DOM编程_第一天复习 Posted on 2019-07-20 In javascript Views: 本节最主要的是区别nodeValue和value:代码如下…… Dom-6.html: 123456789101112131415161718192021222324252627282930313233343536373839404142434445<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>节点的属性</title> <script type="text/javascript"> window.onload = function(){ //最主要的是区别nodeValue和value var nameNode = document.getElementById("name"); alert(nameNode.nodeValue); alert(nameNode.nodeType); alert(nameNode.value); nameNode.value = "测试"; } </script> </head> <body> <p>你喜欢哪个城市?</p> <ul id="city"> <li id="bj" name="BeiJing" value="测试">北京</li> <li>上海</li> <li>东京</li> <li>首尔</li> </ul> <br><br> <p>你喜欢哪款单机游戏?</p> <ul id="game"> <li id="rl">红警</li> <li>实况</li> <li>极品飞车</li> <li>魔兽</li> </ul> <br><br><!-- gender: <input type="radio" name="gender" value="male"/>Male <input type="radio" name="gender" value="female"/>Female --> name: <input type="text" name="username" id="name" value="cyqand" /> </body></html>