13_JavaScript_DOM编程_innerHTML属性 Posted on 2019-07-20 In javascript Views: 本节主要了解innerHTML的属性…… 详见代码演示: dom-11.html 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253<!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(){ var cityNode = document.getElementById("city"); var gameNode = document.getElementById("game"); //alert(cityNode.innerHTML); //现在有一个需求将cityNode和gameNode互换内容 var tempHTML = cityNode.innerHTML; cityNode.innerHTML = gameNode.innerHTML; gameNode.innerHTML = tempHTML; } </script> </head> <body> <p>你喜欢哪个城市?</p> <ul id="city"><li id="bj" name="BeiJing">北京</li> <li>上海</li> <li>东京</li> <li id="se">首尔</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 <br><br> name: <input type="text" name="username" value="atguigu"/> </body></html>