-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
Iss1410 #3256
Iss1410 #3256
Conversation
Fixes #2658
Instead of using onclick html attribute used here an event listener
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CreaTorAlexander there are a couple of problems here, and this code snippet won't work as it stands:
Document.querySelector()
doesn't take a second argument of a function to invoke. You'd have to do this using something likeaddEventListener()
instead.addAttribute()
doesn't exist —setAttribute()
is what you need.
the following works:
const btn = document.querySelector('button');
btn.addEventListener('click', triggerAlert);
function triggerAlert() {
var alertEl = document.querySelector('.alert');
console.log(alertEl)
alertEl.setAttribute('role', 'alert');
}
Make sure you test code snippets before submitting.
Damn sorry, did it in the GitHub UI what was obviously here a mistake. |
No need to apologize at all. We all make mistakes sometimes, and what you do for us is hugely helpful. |
@chrisdavidmills is there a reason for the console.log? |
Oh, no, there isn't! That was leftover from a test I did. you can remove that ;-) |
Okay, I assumed it so I already did a PR. #3270 |
Fixes #1410
Instead of using the onclick html attribute here we use an eventlistener
I don't know why the other commit with #2658 is here it should already merged, but idk how to remove this commit.