forked from AI-Collaboratory/INST742-git
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathobjects.html
54 lines (37 loc) · 848 Bytes
/
objects.html
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
<html>
<head>
<style type="text/css">
.square {
margin-top: 50px;
margin-left: 100px;
}
div {
margin-bottom: 20px;
}
</style>
</head>
<body>
<div id="container"></div>
<script>
function Square (width, height, color, classname){
this.width = width;
this.height = height;
this.background = color;
// creates a div tag inside the "container" object.
sq = document.getElementById("container").appendChild(document.createElement("div"))
sq.setAttribute("class", classname);
sq.setAttribute("style", "height:" + this.height);
sq.style.width = this.width;
sq.style.background = this.background;
this.changeColor = function(c){
this.background = c;
sq.style.background = this.background;
}
// Task 3
}
s1 = new Square("200px", "50px", "grey", "square")
// Task 1
// Task 2
</script>
</body>
</html>