From ac100b12cca506cc19cfa58682f7b1b26c4f4cf6 Mon Sep 17 00:00:00 2001 From: spencerspe Date: Mon, 3 Jul 2023 14:03:07 +0100 Subject: [PATCH] first solution --- src/index.html | 2 +- src/scripts/main.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index 0b87f98a..1b7e2bb9 100644 --- a/src/index.html +++ b/src/index.html @@ -4,7 +4,7 @@ Login - +
diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1..dac604bd 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,24 @@ 'use strict'; // write code here + +const inputs = document.querySelectorAll('input'); + +const inputsAsArray = Array.from(inputs); + +inputsAsArray.forEach(entry => { + const label = document.createElement('label'); + + const placeHolder = entry.name.charAt(0).toLocaleUpperCase() + + entry.name.toLocaleLowerCase().slice(1); + + entry.placeholder = placeHolder; + + label.classList.add(`field-label`); + + label.setAttribute('for', entry.id); + + label.insertAdjacentText('afterbegin', entry.name); + + entry.before(label); +});