-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path10-dom-projects.html
More file actions
100 lines (84 loc) · 3.02 KB
/
10-dom-projects.html
File metadata and controls
100 lines (84 loc) · 3.02 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
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html>
<head>
<title>DOM Projects</title>
<style>
.subscribe-button{
background-color: black;
border: none;
color: white;
border-radius:50px ;
padding-left: 15px;
padding-top: 10px;
padding-right: 15px;
padding-bottom: 10px;
font-weight: bold;
cursor: pointer;
margin-bottom: 30px;
}
.is-subscribed{
background-color: rgb(240,240,240);
color: black;
}
body{
font-family: Arial, Helvetica, sans-serif;
}
.cost-input{
font-size: 15px;
padding-left: 10px;
padding-top: 10px;
padding-bottom: 10px;
padding-right: 10px;
}
.calculate-tot{
font-size: 15px;
padding: 10px 15px;
border: none;
background-color:green;
color: white;
}
</style>
</head>
<body>
<p>You Tube subscribe button</p>
<button onclick="
subscribe();
" class="js-subscribe-button subscribe-button">Suscribe</button>
<p>Amazon shipping calculator</p>
<input placeholder="cost of order" class="js-cost-input cost-input" onkeydown="
handlecostkeydown(event);
">
<button onclick="
" class="calculate-tot">calculate</button>
<p class="js-total-cost "></p>
<script>
function handlecostkeydown(event){
if(event.key=== 'Enter'){
calculateTotal();
}
}
function calculateTotal(){
const inputElement = document.querySelector('.js-cost-input');
console.log(inputElement.value);
let cost = Number(inputElement.value);
console.log(cost);
if(cost< 40){
cost=cost+10;
console.log(cost);
}
document.querySelector('.js-total-cost')
.innerHTML = `$${cost}`;
}
function subscribe(){
const buttonElement = document.querySelector('.js-subscribe-button');
if(buttonElement.innerText === 'Suscribe'){
buttonElement.innerHTML = 'Suscribed';
buttonElement.classList.add('is-subscribed')
} else{
buttonElement.innerHTML='Subscribe';
buttonElement.classList.remove('is-subscribed');
}
}
</script>
</body>
</html>