标签:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>使用Document方法</title> <style type="text/css"> body{font-size:14px; line-height:30px; } input{margin:1px; width:90px; font-size:12px; padding:0; } #node{ width:100px; font-size:24px; font-weight:bold; float: left; } </style> <script type="text/javascript"> function changeLink(){ document.getElementById("node").innerHTML="搜狐"; } function all_input(){ var aInput=document.getElementsByTagName("input"); var sStr=""; for(var i=0;i<aInput.length;i++){ sStr+=aInput[i].value+"<br />"; } document.getElementById("s").innerHTML=sStr; } function s_input(){ var aInput=document.getElementsByName("season"); var sStr=""; for(var i=0;i<aInput.length;i++){ sStr+=aInput[i].value+"<br />"; } document.getElementById("s").innerHTML=sStr; } </script> </head> <body> <div id="node">新浪</div> <input name="b1" type="button" value="改变层内容" onclick="changeLink();" /><br /> <br /><input name="season" type="text" value="春" /> <input name="season" type="text" value="夏" /> <input name="season" type="text" value="秋" /> <input name="season" type="text" value="冬" /> <br /><input name="b2" type="button" value="显示input内容" onclick="all_input()" /> <input name="b3" type="button" value="显示season内容" onclick="s_input()" /> <p id="s"></p> </body> </html>
标签:
原文地址:http://www.cnblogs.com/xiaotaoxu/p/5544557.html