标签:src id3 elements ima eva 名称 var lan script
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>docuemnt</title> <script type="text/javascript"> window.onload = function () { var id1 = document.getElementById("id1"); console.log(id1.value) } </script> </head> <body> <input type="text" id="id1" name="sex" value="男" /> <input type="text" id="id2" name="sex" value="女"/> <input type="password" id="id3" name="password" value="123"/> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>docuemnt</title> <script type="text/javascript"> window.onload = function () { var sex = document.getElementsByName("sex"); for(var x =0;x<sex.length;x++){ console.log(sex[x].value); } } </script> </head> <body> <input type="text" id="id1" name="sex" value="男" /> <input type="text" id="id2" name="sex" value="女"/> <input type="password" id="id3" name="password" value="123"/> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>docuemnt</title> <script type="text/javascript"> window.onload = function () { var input = document.getElementsByTagName("input"); for(var x =0;x<input.length;x++){ console.log(input[x].value); } } </script> </head> <body> <input type="text" id="id1" name="sex" value="男" /> <input type="text" id="id2" name="sex" value="女"/> <input type="password" id="id3" name="password" value="123"/> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Node</title> <script type="text/javascript"> window.onload = function () { var div = document.getElementById("div"); //元素节点的nodeName nodeType nodeValue console.log(div.nodeName+":"+div.nodeType+":"+div.nodeValue) } </script> </head> <body> <div id="div" style="width: 500px;height: 500px;background-color: aqua"> 牛逼的人总在默默努力,不牛逼的人总在吹牛逼 </div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Node</title> <script type="text/javascript"> window.onload = function () { var div = document.getElementById("div"); var styleNode = div.getAttributeNode("style");//xml dom获取元素的属性节点 console.log(styleNode.nodeName +":" +styleNode.nodeType+":"+styleNode.nodeValue) } </script> </head> <body> <div id="div" style="width: 500px;height: 500px;background-color: aqua"> 牛逼的人总在默默努力,不牛逼的人总在吹牛逼 </div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Node</title> <script type="text/javascript"> window.onload = function () { var div = document.getElementById("div"); var textNode = div.firstChild; console.log(textNode.nodeName +":"+textNode.nodeType+":"+textNode.nodeValue) } </script> </head> <body> <div id="div" style="width: 500px;height: 500px;background-color: aqua"> 牛逼的人总在默默努力,不牛逼的人总在吹牛逼 </div> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script type="text/javascript"> window.onload = function () { var edu = document.getElementById("edu"); var child = edu.childNodes; for(var x =0;x<child.length;x++){ if(child[x].nodeType ==1){ console.log(child[x].firstChild.nodeValue); } } } </script> </head> <body> <select id="edu" name="edu"> <option>博士</option> <option>硕士</option> <option>本科</option> <option>专科</option> <option>高中</option> <option>初中</option> <option>小学</option> <option>幼儿园</option> </select> </body> </html>
标签:src id3 elements ima eva 名称 var lan script
原文地址:http://www.cnblogs.com/xuweiweiwoaini/p/7739660.html