Skip to content

fix: renamed alert variable to alertBox to avoid conflict with window. #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions 14-grocery-bud/final/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ****** select items **********

const form = document.querySelector(".grocery-form");
const alert = document.querySelector(".alert");
const alertBox = document.querySelector(".alert"); //renamed
const grocery = document.getElementById("grocery");
const submitBtn = document.querySelector(".submit-btn");
const container = document.querySelector(".grocery-container");
Expand Down Expand Up @@ -75,15 +75,15 @@ function addItem(e) {
}
// display alert
function displayAlert(text, action) {
alert.textContent = text;
alert.classList.add(`alert-${action}`);
// remove alert
alertBox.textContent = text;
alertBox.classList.add(`alert-${action}`);
setTimeout(function () {
alert.textContent = "";
alert.classList.remove(`alert-${action}`);
alertBox.textContent = "";
alertBox.classList.remove(`alert-${action}`);
}, 1000);
}


// clear items
function clearItems() {
const items = document.querySelectorAll(".grocery-item");
Expand Down