-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
37 lines (35 loc) · 1.54 KB
/
main.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
const elName = document.querySelector("#name");
const elPhone = document.querySelector("#phone");
const elMail = document.querySelector("#email");
const elLocation = document.querySelector("#location");
const elMessage = document.querySelector("#message");
const elBtn = document.querySelector("#btn-submit");
const elCards = document.querySelector(".cards");
const elForm = document.querySelector("#contact-form")
elBtn.addEventListener("click", function(evt){
evt.preventDefault();
if(elName.value !== ""){
const newCard = document.createElement("div");
newCard.className = "card mt-5";
newCard.style.width = "20rem";
newCard.innerHTML = `
<div>
<h3 class="text-center"><b>Person</b></h3>
<div class="card-header">
Info
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item"><i class="fa fa-user" aria-hidden="true"></i> ${elName.value}</li>
<li class="list-group-item"><i class="fa fa-phone" aria-hidden="true"></i> ${elPhone.value}</li>
<li class="list-group-item"><i class="fa fa-envelope" aria-hidden="true"></i> ${elMail.value}</li>
<li class="list-group-item"><i class="fa fa-map-marker" aria-hidden="true"></i> ${elLocation.value}</li>
</ul>
</div>
`
elCards.appendChild(newCard)
elForm.reset()
}
else{
alert("Fill out the contact information")
}
})