-
-
Notifications
You must be signed in to change notification settings - Fork 496
/
script.js
37 lines (30 loc) · 901 Bytes
/
script.js
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
// Made a div
const div = document.createElement("div");
// added class Flower to it
div.classList.add("Flower");
// appended this div to body of html
document.body.appendChild(div);
// made an unordered list with any three items
const myList = `
<ul>
<li>Rose</li>
<li>Sunflower</li>
<li>Lily</li>
</ul>
`;
// Added Mylist to class Flower using innerHTML property
div.innerHTML = myList;
// Created an image and added class & attributes[src, width, height, alt]
const img = document.createElement("img");
img.src =
"https://upload.wikimedia.org/wikipedia/commons/f/fb/Carabao_mangoes_%28Philippines%29.jpg";
img.height = 250;
img.width = 250;
img.classList.add("fruit");
img.alt = "mango";
div.appendChild(img);
// A little animation [on doubleclicking on image it toggles]
function toggleIt() {
img.classList.toggle("round");
}
img.addEventListener("dblclick", toggleIt);