Questions tagged [addeventlistener]
a DOM event method that adds an event listener to a given DOM node
addeventlistener
4,459
questions
0
votes
2
answers
22
views
Can I use an event listener with two events?
I am doing a "pixel art" web page, and I don't want the "pencil" to draw when I am not pressing the button on the mouse, I try to do this but either I can make the "pencil&...
0
votes
0
answers
53
views
The Enter key works every time I call addEventListener ("click")
I'm trying to make a calculator, and in the middle of the coding, I see that when I press the enter key, he calls the last addEventListener ("click") I used, but I don't set any work for the ...
0
votes
0
answers
8
views
handle multiple tabs with listener
I want to create an event listener on every new tab user creates when clicking on any pages, is it possible? this is required to capture user events based on clicks within this new tabs. Like a ...
-1
votes
0
answers
37
views
window.addEventListener does not work on iOS
I want to write a function to listen to sessionStorage. I found that the following code works fine on both computers and Android phones, but it suddenly stopped working on iOS phones recently. Does ...
-1
votes
2
answers
54
views
Changing CSS display property with JS EventListener
I am trying to add functionality to a button on a project I'm working on...when the button is pressed I want an element to no longer show on the page. However, I can't get this process to work. Here ...
-1
votes
2
answers
41
views
How can I select HTML elements which are rendered after DOM
I want to select OKBTN
let main = document.querySelector("#main");
let okBtn = document.querySelector("#ok");
function myAlert(title,msg,icon){
let card = "";
...
0
votes
0
answers
44
views
what is the error in my code (javascript), why it is not looping over my array? [duplicate]
My script is not looping over my array. There is always an error showing. Please find what's the error is. I really can't find it. I tried this multiple time but its not working. Im trying to make a ...
-1
votes
1
answer
24
views
dblclick, onmouseover events not working for me ( i am using chrome)
const b = document.querySelector('#but');
b.addEventListener('dblclick', () => {
console.log('dblclick');
});
b.addEventListener('mouseenter', () => {
console.log('mouseenter');
});
b....
0
votes
1
answer
46
views
Why does the action handler function always capture the initial value of `useState`? [duplicate]
I have view where I want to add a scroll action listener to. I want to get the current scroll offset and compare its previous value to do something. Here is code:
const StickyBox = () => {
const [...
0
votes
0
answers
26
views
Webpage not updating content when mobile screen resizes
I have created a webpage and made it responsive only for horizontal phone screens. So i've tried to implement eventlisteners. If the phone screen is vertical, I will not display the content, however ...
0
votes
2
answers
34
views
event listener only updates innerHTML on odd numbered circumstances
I have an index of projects that I want to be able to filter on click. The filter itself works fine on every click with the following code by hiding the visibility of non-highlighted projects, but the ...
0
votes
0
answers
27
views
what is the 'this' keyword in the .on method's callback function of leaflet library?
Im curious because the this keyword inside of JavaScript's event handler function is the element in which the .eventListener() is attached to. And the .on() method of leaflet library is similar to ....
0
votes
0
answers
44
views
Lighthouse couldn't run because "The page did not paint any content" (NO_FCP)
I'm having an issue running a Lighthouse test on a page I'm testing. I think I've found the root of the problem - but I don't fully understand why it is causing a problem at the exact same script ...
0
votes
1
answer
27
views
Javascript jQuery activate a class method after click event in class object [duplicate]
syntax for starting the class method
Creation of myClass is oke but when event the method of the class doesn't work
class myClass {
constructor(toElement, options) {
var self = this;
this....
1
vote
1
answer
43
views
Why aren't my event listeners being removed?
public zoom(dragZoomActive: boolean): void {
const onMouseDown = (event: MouseEvent) => {
/*code*/
}
const onMouseMove = (event: MouseEvent) => {
/*code*/
}
...