Skip to content

Commit

Permalink
add task solution
Browse files Browse the repository at this point in the history
  • Loading branch information
P-Nazar committed Apr 23, 2024
1 parent 9c9cf2e commit af4a64f
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 90 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1. Replace `<your_account>` with your Github username in the link
- [DEMO LINK](https://<your_account>.github.io/js_task_fix_form_DOM/)
- [DEMO LINK](https://P-Nazar.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;
Expand Down
213 changes: 126 additions & 87 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@linthtml/linthtml": "^0.9.5",
"@mate-academy/eslint-config": "latest",
"@mate-academy/linthtml-config": "latest",
"@mate-academy/scripts": "^1.7.5",
"@mate-academy/scripts": "^1.8.1",
"@mate-academy/stylelint-config": "latest",
"@parcel/transformer-sass": "^2.12.0",
"cypress": "^9.7.0",
Expand Down
20 changes: 19 additions & 1 deletion src/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
'use strict';

// write code here
const inputs = document.querySelectorAll('form input');

inputs.forEach((input) => {
const label = document.createElement('label');

label.classList.add('field-label');

label.setAttribute('for', input.id);

input.insertAdjacentElement('afterend', label);

const placeholder = input.name.charAt(0).toUpperCase() + input.name.slice(1);

input.setAttribute('placeholder', placeholder);

label.textContent = placeholder;

input.parentElement.appendChild(label);
});

0 comments on commit af4a64f

Please sign in to comment.