-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomProject.html
86 lines (79 loc) · 2.26 KB
/
domProject.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOM Projects</title>
<style>
body{
font-family:arial;
}
button.subsBtn{
padding: 10px;
padding-left: 15px;
padding-right: 15px;
background-color: black;
color: white;
border-radius: 28px;
font-weight: bold;
cursor: pointer;
margin-bottom: 30px;
}
button.subscribedNew{
background-color: white;
color: black;
border-color: white;;
}
input.calInp {
padding: 10px;
}
h4.am{
font-size: 15px;
}
button.calbtn{
background-color: green;
color: white;
padding: 10px;
}
</style>
</head>
<body>
<H4>YouTube Subscribe Button</H4>
<button class="subsBtn" onclick="subscribeFun()">Subscribe</button>
<p>Rock Paper Scisoors <a href="rock_paper_function_object.html">Click here</a></p>
<h4 class="am">Amazon Shipping Calculator</h4>
<p>Orders Under $40 = $10 Shipping.<br>Order Over $40 = Free Shipping.</p>
<input placeholder="Enter Amount" class="calInp" onkeydown="handCosy(event)">
<button onclick="shippingCal()" class="calbtn">Calculate</button>
<p class="displayCost"></p>
<script>
function subscribeFun(){
const btnElement = document.querySelector('.subsBtn');
if(btnElement.innerHTML === 'Subscribe'){
btnElement.innerHTML = 'Subscribed';
btnElement.classList.add('subscribedNew');
}else{
btnElement.innerHTML = 'Subscribe';
btnElement.classList.remove('subscribedNew');
}
}
//function for shipping cal
function shippingCal(){
const inputEle = document.querySelector('.calInp');
let inpValue = Number(inputEle.value);
if(inpValue < 40){
inpValue = (inpValue*100) + 1000; //convert into cents
}else{
inpValue = inpValue;
}
document.querySelector('.displayCost')
.innerHTML = `$${(inpValue)/100}`; //convert back into $$
}
function handCosy(event){
if(event.key === 'Enter'){
shippingCal();
}
}
</script>
</body>
</html>