1
2
3
4
5
6 document.addEventListener("DOMContentLoaded", function() {
7
8 });
9
10
11
12
13 var divs = document.querySelectorAll("div");
14
15
16
17
18 var newDiv = document.createElement("div");
19
20
21
22
23 newDiv.classList.add("foo");
24
25
26
27
28 newDiv.classList.toggle("foo");
29
30
31
32
33
34
35 [].forEach.call(document.querySelectorAll("a"), function(el) {
36 el.addEventListener("click", function() {
37
38 });
39 });
40
41
42
43
44 document.body.appendChild(document.createElement("p"));
45
46
47
48
49 document.querySelector("img").setAttribute("alt", "My image");
50
51
52
53
54 var parent = document.getElementById("about").parentNode;
55
56
57
58
59 var clonedElement = document.getElementById("about").cloneNode(true);
60
61
62
63
64 var wrap = document.getElementById("wrap");
65 while(wrap.firstChild) wrap.removeChild(wrap.firstChild);
66
67
68
69
70 if(!document.getElementById("wrap").hasChildNodes())
71
72
73
74
75 var nextElement = document.getElementById("wrap").nextSibling;
CategoryCheatSheet
SamatsWiki: CheatSheet/jQueryToJavaScript (last edited 2012-01-09 14:07:03 by SamatJain)