Introduction to event listeners
Created by Codedamn about a year ago
No description provided
13 Comments
Hi Mehul, can you help me to check this error? I thought I've already gotten along with those codes. It seems that something is wrong with the node.innerText = counter. "Uncaught TypeError: Cannot set properties of null (setting 'innerText')". Thanks in advance.
difference between calling the function and passing the name of the function?
you didnt teach us "getelementbyid" , and how do you expect us to know and apply the differnce between queryselector and getelementById. Please update the video.
Where can I find the code demonstrated in this video?
This is where things start to become real 😎
Hi. Why you used querySelector and getelementById? What's the difference?
whats the difference if I add my script reference before or after body tag . Becuase when I added script reference inside head tag I got the error like 'uncaught error....'
5.05k views till 19 jan 2023
every element has a unique id ,which differs it from rest of list of elements in the DOM. we can say id here is name or address of each node i.e element of DOM returned by Java script which must identify the elements uniquely. https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementById
In this line, "const counterEL = document.getElementById('counter');", counter shouldve been #counter right? because "counter" is the id of the span element in HTML?
someone can plz tell me whats wrong with my code
const incrementBtn = document.querySelector('#increment') let counter = 0
function incrementCounter() { const counteEL = document.getElementById('#counter') counter++ counteEL.innerText = counter }
incrementBtn.addEventListener('click',incrementCounter)
I really enjoyed this lesson, feels like things are starting to happen, kinda feel that magic if that makes any sense :) I wish you had more practical lessons to try and make the lessons stick a little bettter, without having to go to my own ide to play about.
I Can't get outputs in the browser log just like the video in my own codedamn's playground. I have to go into the chrome's console to see the output.I case of the javascript.