-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjectMethod.html
More file actions
69 lines (62 loc) · 1.55 KB
/
objectMethod.html
File metadata and controls
69 lines (62 loc) · 1.55 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Object</title>
<style>
#book {
display: flex;
flex-direction: column;
gap: 15px;
}
.book-card {
background-color: rgb(203, 203, 218);
color: #202a17;
border: 1px solid #ccc;
padding: 15px;
border-radius: 5px;
transition: all 0.3s ease;
}
.book-card:hover {
background-color: rgb(5, 5, 80);
color: white;
transform: scale(1.05);
}
</style>
</head>
<body>
<div id="book">
</div>
<script>
let books = [
{
name: "The Alchemist",
price: 200,
author: "Paulo Coelho",
getDetails() {
return `Book: ${this.name}<br>Author: ${this.author}<br>Price: ₹${this.price}`;
}
},
{
name: "The Life of Pi",
price: 300,
author: "Paulo Fernando",
getDetails() {
return `Book: ${this.name}<br>Author: ${this.author}<br>Price: ₹${this.price}`;
}
},
{
name: "How to Love Yourself",
price: 400,
author: "Pawan Krishna",
getDetails() {
return `Book: ${this.name}<br>Author: ${this.author}<br>Price: ₹${this.price}`;
}
}
];
document.getElementById("book").innerHTML =
books.map(book => `<div class="book-card">${book.getDetails()}</div>`).join("");
</script>
</body>
</html>