Skip to content
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

Another Issue in the JS modal button comand #6

Open
AbodyHisham opened this issue Feb 20, 2022 · 2 comments
Open

Another Issue in the JS modal button comand #6

AbodyHisham opened this issue Feb 20, 2022 · 2 comments

Comments

@AbodyHisham
Copy link

Idk why it gives me this error please help ! the error shown below is (

javascript.js:16

Uncaught TypeError: Cannot read properties of null (reading 'forEach')

at javascript.js:16:11 )

const modalViews = document.querySelector('services__modal');
const modalBtns = document.querySelector('services__button');
const modalClose = document.querySelector('services__modal-close');

let modal = function(modalClick){
modalViews[modalClick].classList.add('active-modal')
}

modalBtns.forEach((mb,i) => {
mb.addEventListener('click' , () => {
modal(i)
})
});

@PabloA-Development
Copy link

PabloA-Development commented Feb 27, 2022

hello AbodyHisham, the problem is in the syntax, since you are writing the ".querySelector" command wrong since it is missing the word "all" at the end, the correct form would be the following: "modalBtns = document.querySelectorAll('.services__button '),".

I hope I helped you bro

@AbodyHisham
Copy link
Author

AbodyHisham commented Feb 27, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants