From 84494130450e0e5c5651c43b6facbefdd430642f Mon Sep 17 00:00:00 2001 From: cookieru Date: Tue, 6 Feb 2024 01:56:50 +0500 Subject: [PATCH] update #10 add new buttons --- bjs/10_function_object/index.html | 4 ++-- bjs/10_function_object/init.js | 35 ++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/bjs/10_function_object/index.html b/bjs/10_function_object/index.html index 0dddf02..5440353 100644 --- a/bjs/10_function_object/index.html +++ b/bjs/10_function_object/index.html @@ -34,8 +34,8 @@

Отчество:Генерация отчест diff --git a/bjs/10_function_object/init.js b/bjs/10_function_object/init.js index 141ada8..784747e 100644 --- a/bjs/10_function_object/init.js +++ b/bjs/10_function_object/init.js @@ -1,12 +1,31 @@ - -window.onload = function() +const load = function() { const initPerson = personGenerator.getPerson(); - document.querySelector('#firstNameOutput').innerText = initPerson.firstName; - document.querySelector('#surnameOutput').innerText = initPerson.surName; - document.querySelector('#fatherNameOutput').innerText = initPerson.fathername; - document.querySelector('#genderOutput').innerText = initPerson.gender; - document.querySelector('#birthYearOutput').innerText = initPerson.birthday; - document.querySelector('#jobOutput').innerText = initPerson.job; + + console.log(initPerson); + + document.querySelector('#firstNameOutput').textContent = initPerson.firstName; + document.querySelector('#surnameOutput').textContent = initPerson.surName; + document.querySelector('#fatherNameOutput').textContent = initPerson.fathername; + document.querySelector('#genderOutput').textContent = initPerson.gender; + document.querySelector('#birthYearOutput').textContent = initPerson.birthday; + document.querySelector('#jobOutput').textContent = initPerson.job; +}; + +const clear = function() +{ + document.querySelector('#firstNameOutput').textContent = "-"; + document.querySelector('#surnameOutput').textContent = "-"; + document.querySelector('#fatherNameOutput').textContent = "-"; + document.querySelector('#genderOutput').textContent = "-"; + document.querySelector('#birthYearOutput').textContent = "-"; + document.querySelector('#jobOutput').textContent = "-"; + + }; +addEventListener("load", load); + +document.querySelector("#reloadBtn").addEventListener("click", load); + +document.querySelector("#clearBtn").addEventListener("click", clear);