-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDOM.html
More file actions
92 lines (76 loc) · 3.3 KB
/
DOM.html
File metadata and controls
92 lines (76 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
div,p {
border: 1px solid;
border-color: rgb(256,0,0);
transition-duration: 0.5s;
}
.foo {
width: 100%;
height: 100%;
position: fixed;
top: 0px;
left: 0px;
background: rgb(50,50,50);
}
</style>
<script type='text/javascript'>
//function captureClick() {
// e = window.event;
// console.log(e.target);
// }
function getNext(element){
console.log("Next node is: ");
current = element.target;
var nextThing = null;
if(current.firstElementChild) {
nextThing = current.firstElementChild;
}
else if(current.nextElementSibling) {
nextThing = current.nextElementSibling;
}
else
{
while(!current.parentNode.nextElementSibling) {
current = current.parentNode;
}
if(current.parentNode.nextElementSibling.tagName == 'SCRIPT')
{
current = current.parentNode.nextElementSibling;
while(current.parentNode.tagName != 'BODY') {
current = current.parentNode;
}
nextThing = current.parentNode.firstElementChild;
}
else
{
nextThing = current.parentNode.nextElementSibling;
}
}
console.log(nextThing);
}
window.onclick = getNext;
</script>
</head>
<body>
<div class="foo">
<div id="one" style="width: 100px; float:left; height:100px; background:magenta; margin:20px"><p> 1</p></div>
<div style="width: 100px; float:left; height:100px; background:magenta; margin:20px">
<p>2</p>
<p>2</p>
</div>
<div style="width: 100px; float:left; height:100px; background:magenta; margin:20px"><p>Div 3</p></div>
<div style="width: 200px; float:right; height:100px; background:magenta; margin:20px"><p>Div 4</p></div>
<div style="width: 200px; clear:both; float:left; height:100px; background:magenta; margin:20px"><p>Hellow</p></div>
<div style="width: 100px; clear:both; float:left; height:100px; background:magenta; margin:20px"><p>Start</p></div>
<div style="width: 100px; float:right; height:100px; background:magenta; margin:20px"><p>Div 5</p></div>
<div style="width: 100px; float:right; height:100px; background:magenta; margin:20px"><p>Div 6</p></div>
<div style="width: 400px; float:right; margin:20px">
<div style="float:right; background-color:green; width:100px; height:100px; margin-top:100px; margin-right: 1px;">one</div>
<div style="float:left; background-color:green; width:100px; height:100px; margin-top:100px; margin-left: 50px;">two</div>
</div>
</div>
</body>
</html>