diff --git a/README.md b/README.md index d24722b51..00ddf8c66 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/) +1. Replace `elenachernyshova01-cmd` with your Github username in the link + - [DEMO LINK](https://elenachernyshova01-cmd.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/package-lock.json b/package-lock.json index 72d06cb5f..c8e3a59fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3831,17 +3831,6 @@ "@parcel/core": "^2.16.4" } }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "optional": true, - "peer": true, - "engines": { - "node": ">=14" - } - }, "node_modules/@pkgr/core": { "version": "0.2.9", "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.2.9.tgz", diff --git a/src/scripts/main.js b/src/scripts/main.js index a765fdb1d..9d1da2f43 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -1,3 +1,22 @@ 'use strict'; // write code here +const inputs = document.querySelectorAll('form input'); + +inputs.forEach((input) => { + const { name: inputName, id } = input; + + const label = document.createElement('label'); + + label.classList.add('field-label'); + + label.setAttribute('for', id); + + const labelText = inputName.charAt(0).toUpperCase() + inputName.slice(1); + + label.textContent = labelText; + + input.placeholder = labelText; + + input.parentElement.prepend(label); +});