1//<div id="demo-id"></div>
2var elem1 = document.getElementById("demo-id");
3//<div class="demo-class"></div>
4var elem2 = document.getElementsByClassName("demo-class");
5//<div name="demo-name"></div>
6var elem3 = document.getElementsByName("demo-name");
7//<p>Some text</p>
8var elem4 = document.getElementsByTagName("p");
9
10//<div id="demo-id"></div>
11var elem1 = document.querySelector("#demo-id");
12//<div class="demo-class"></div>
13var elem2 = document.querySelectorAll(".demo-class");
14//<div name="demo-name"></div>
15var elem3 = document.querySelectorAll('[name="demo-name"]');
16//<p>Some text</p>
17var elem4 = document.querySelectorAll("p");
1// Selecting an Element by id:
2document.getElementById("elem-id");
3// Selecting Elements by class:
4document.getElementsByClassName("elem-class");
5// Selecting Elements by tag name:
6document.getElementsByTagName("div");
7// Selecting Elements by name:
8document.getElementsByName("elem-name");
9/* This method is like a jQuery selector
10( #elemId -> id, .elemClass -> class, h1 -> tag name) */
11document.querySelector(".container"); // class
12document.querySelector("#demo"); // id
13document.querySelector("div"); // tag name
1var elem1 = document.getElementById("demo-id");
2//<div class="demo-class"></div>
3var elem2 = document.getElementsByClassName("demo-class");
4//<div name="demo-name"></div>
5var elem3 = document.getElementsByName("demo-name");
6//<p>Some text</p>
7var elem4 = document.getElementsByTagName("p");
8
9//<div id="demo-id"></div>
10var elem1 = document.querySelector("#demo-id");
11//<div class="demo-class"></div>
12var elem2 = document.querySelectorAll(".demo-class");
13//<div name="demo-name"></div>
14var elem3 = document.querySelectorAll('[name="demo-name"]');
15//<p>Some text</p>
16var elem4 = document.querySelectorAll("p");