From c114ba914303e68457b40fd75ede12db94573f36 Mon Sep 17 00:00:00 2001 From: Yaroslav Volkov Date: Thu, 4 Jun 2026 22:43:47 +0200 Subject: [PATCH] solution 2 --- README.md | 2 +- src/scripts/main.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d24722b51..442e56c32 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ 1. Replace `` with your Github username in the link - - [DEMO LINK](https://.github.io/js_task_fix_form_DOM/) + - [DEMO LINK](https://PatronXXi.github.io/js_task_fix_form_DOM/) 2. Follow [this instructions](https://mate-academy.github.io/layout_task-guideline/) - Run `npm run test` command to test your code; - Run `npm run test:only -- -n` to run fast test ignoring linter; diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1d..68e19d087 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,16 @@ 'use strict'; // write code here + +const inputs = document.querySelectorAll('form input'); + +inputs.forEach((input) => { + const names = input.name; + const label = document.createElement('label'); + + label.classList.add('field-label'); + label.htmlFor = input.id; + label.textContent = names; + input.placeholder = names.charAt(0).toUpperCase() + names.slice(1); + input.parentElement.appendChild(label); +});