Home > Article > Web Front-end > Band of Brothers JavaScript video material sharing
Brothers, as everyone must know, is one of the best training institutions in the training industry. It is very famous because of its high quality. Therefore, the quality of Band of Brothers' courses is also very high. Everyone should read it and study hard. You should gain a lot after studying.
"Band of Brothers JavaScript Video Tutorial" This is a course to help you learn the JavaScript programming language systematically. This course introduces the language features of JavaScript from the shallower to the deeper, analyzes common misunderstandings with practical examples, inspires your thinking, and helps Learners improve your JavaScript skills from beginner to mastery.
Video playback address: http://www.php.cn/course/240.html
This video is javascript Basic video, so the difficulty lies in everyone’s understanding and mastery of the basic concepts. For example, DOM operations, javascript event objects,
1. document.getElementById() Get element nodes based on Id
<p id="p1"> <p id="p1"> 我是第一个P</p> <p id="p2"> 我是第二个P</p> </p> window.onload = function () { var str = document.getElementById("p1").innerHTML; alert(str); //弹出 我是第一个P }
2. document.getElementsByName() Get element nodes based on name
<p id="p1"> <p id="p1"> 我是第一个P</p> <p id="p2"> 我是第二个P</p> <input type="text" value="请输入值" name="userName" /> <input type="button" value="确定" onclick="fun1()"> </p> function fun1() { var username = document.getElementsByName("userName")[0].value; alert(username); //输出userName里输入的值 }
3. document.getElementsByTagName() Get element nodes based on HTML tag names. Note that the selector of getElements*** returns a NodeList object. One of them can be selected based on the index number, and the output can be traversed.
<p id="p1"> <p id="p1"> 我是第一个P</p> <p id="p2"> 我是第二个P</p> </p> window.onload = function () { var str = document.getElementsByTagName("p")[1].innerHTML; alert(str); //输出 我是第二个P,因为获取的是索引为1的P,索引从0开始 } window.onload = function () { var arr = document.getElementsByTagName("p"); for (var i = 0; i < arr.length; i++) { alert(arr[i].innerHTML); } } window.onload = function () { var node = document.getElementById("p1"); var node1 = document.getElementsByTagName("p")[1]; //从获取到的元素再获取 alert(node1.innerHTML); }
The above is the detailed content of Band of Brothers JavaScript video material sharing. For more information, please follow other related articles on the PHP Chinese website!