Can someone help me figure out how to hide the placeholders when the focus changes in a form? Here is the code snippet that illustrates my problem.
Your assistance is greatly appreciated, João
var inputs = Array.prototype.slice.call(document.querySelectorAll(".inpt"));
var list = ["YOUR NAME", "YOUR E-MAIL ADDRESS", "YOUR PHONE NUMBER"];
var upholder = document.getElementsByClassName("upholder");
var lol = document.getElementById("row-normal-3");
for (i = 0; i < upholder.length; i++) {
upholder[i].classList.add("hide");
}
inputs.forEach(function slideUp(ipt, index) {
ipt.addEventListener("click", function slideUpTwo() {
upholder[index].classList.remove("hide");
upholder[index].classList.add("show");
upholder[index].innerHTML = list[index];
})
})
.show {
display:flex;
}
.hide {
display:none;
}
<div class="le-form">
<form method="POST">
<div class="le-input">
<div class="upholder"></div>
<input class="inpt" type="text" name="name" placeholder="Your name">
</div>
<div class="le-input">
<div class="upholder"></div>
<input class="inpt" type="email" name="_replyto" placeholder="Your e-mail address">
</div>
<div class="le-input">
<div class="upholder"></div>
<input class="inpt" type="text" name="phone" placeholder="Your phone number">
</div>
<input type="submit" value="Send" class="form-btn">
</form>
</div>