Calling a function inside another function?
-
Greetings! I am working on the function of opening multiple popups on the page. I wrote a general opening function, then a function for editing a specific popup, in the body of which I placed a call to the function for opening popups. The console reports an error: Uncaught ReferenceError: popupOpen is not defined at HTMLButtonElement.PopupEditProfile.
I don't quite understand how to define a function in an HTML element.
/*Объявил переменные*/ const popup = document.querySelector('.popup'); const popupProfile = document.querySelector('.popup_profile'); const popupEditButton = document.querySelector('.profile__edit-button'); /*Написал функцию открытия*/ const PopupOpen = function (popup) { popup.classList.add('popup_opened'); } /*Написал функцию редактирования, сначала вызывающую функцию открытия*/ const PopupEditProfile = function () { popupOpen(popupProfile); NameInput.value = profileName.textContent; ProfessionInput.value = profileProfession.textContent; } /*Повесил обработчик на кнопку, вызывающую функцию открытия*/ popupEditButton.addEventListener('click', PopupEditProfile;
JavaScript Juliet Franco, Apr 1, 2019 -
You have a function name with a capital letter, and you call it with a small letter. Bring the register to one form, and everything will work.Penelope Dorsey
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!