Skip to content

Commit 8449413

Browse files
committed
update SkillfactoryCoding#10 add new buttons
1 parent 1c9cce0 commit 8449413

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

bjs/10_function_object/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ <h4>Отчество:<span id="fatherNameOutput">Генерация отчест
3434
</div>
3535
</div>
3636
<div class="card-footer text-right">
37-
<button class="btn btn-primary">Сгенерировать</button>
38-
<button class="btn btn-primary">Очистить</button>
37+
<button class="btn btn-primary" id="reloadBtn">Сгенерировать</button>
38+
<button class="btn btn-primary" id="clearBtn">Очистить</button>
3939
</div>
4040
</div>
4141
</div>

bjs/10_function_object/init.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
1-
2-
window.onload = function()
1+
const load = function()
32
{
43
const initPerson = personGenerator.getPerson();
5-
document.querySelector('#firstNameOutput').innerText = initPerson.firstName;
6-
document.querySelector('#surnameOutput').innerText = initPerson.surName;
7-
document.querySelector('#fatherNameOutput').innerText = initPerson.fathername;
8-
document.querySelector('#genderOutput').innerText = initPerson.gender;
9-
document.querySelector('#birthYearOutput').innerText = initPerson.birthday;
10-
document.querySelector('#jobOutput').innerText = initPerson.job;
4+
5+
console.log(initPerson);
6+
7+
document.querySelector('#firstNameOutput').textContent = initPerson.firstName;
8+
document.querySelector('#surnameOutput').textContent = initPerson.surName;
9+
document.querySelector('#fatherNameOutput').textContent = initPerson.fathername;
10+
document.querySelector('#genderOutput').textContent = initPerson.gender;
11+
document.querySelector('#birthYearOutput').textContent = initPerson.birthday;
12+
document.querySelector('#jobOutput').textContent = initPerson.job;
13+
};
14+
15+
const clear = function()
16+
{
17+
document.querySelector('#firstNameOutput').textContent = "-";
18+
document.querySelector('#surnameOutput').textContent = "-";
19+
document.querySelector('#fatherNameOutput').textContent = "-";
20+
document.querySelector('#genderOutput').textContent = "-";
21+
document.querySelector('#birthYearOutput').textContent = "-";
22+
document.querySelector('#jobOutput').textContent = "-";
23+
24+
1125
};
1226

27+
addEventListener("load", load);
28+
29+
document.querySelector("#reloadBtn").addEventListener("click", load);
30+
31+
document.querySelector("#clearBtn").addEventListener("click", clear);

0 commit comments

Comments
 (0)