This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>DOM Manipulation</title> | |
| </head> | |
| <body> | |
| <p class="para">First Paragraph</p> <!-- 1st node --> | |
| <a href="https://medium.com" class="para">Medium</a> <!-- 2nd node --> | |
| <input type="text" class="para" /> <!-- 3rd node --> | |
| </body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>DOM Manipulation</title> | |
| </head> | |
| <body> | |
| <p id="paraId">First Paragraph</p> | |
| </body> | |
| <script> | |
| //accessing the node with id="paraId" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>DOM Manipulation</title> | |
| </head> | |
| <body> | |
| <p id="paraId">First Paragraph</p> | |
| </body> | |
| <script> | |
| //accessing the node with id="paraId" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>DOM Manipulation</title> | |
| </head> | |
| <body> | |
| <p id="paraId">First Paragraph</p> | |
| </body> | |
| <script> | |
| //creating a new element node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>DOM Manipulation</title> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| </div> | |
| </body> | |
| <script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>DOM Manipulation</title> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| </div> | |
| </body> | |
| <script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Old syntax of defining functions | |
| var blogTitle = function getBlogTitle(id) { | |
| console.log(blog[id].title); | |
| } | |
| blogTitle(2); | |
| //Fat-Arrow syntax | |
| var blogTitle = id => console.log(blog[id].title); | |
| blogTitle(2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Old syntax | |
| var name = function returnName (id) { | |
| return editors[id].name; | |
| } | |
| //Fat-Arrow syntax | |
| var name = id => editors[id].name; //implicit return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function globalFunction() { | |
| console.log(this); | |
| } | |
| globalFunction(); //[object Window] | |
| //globalFunction() is equivalent to window.globalFunction() | |
| var myObj = {name: "obj"}; | |
| myObj.logThis = function () { | |
| console.log(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Old syntax | |
| var blog = { | |
| name: 'The School Of JS', | |
| topics: ['DOM', 'JS'], | |
| about: function () { | |
| return this.topics.map(function (topic) { | |
| return topic + ' is a topic of ' + this.name + ' blog!'; | |
| }); | |
| } | |
| }; |