4,478
questions
0
votes
0
answers
9
views
Close dropdown menu or change element behaviour when click outside the element with reacrjs
I have ul and th li tags rendred from api data I want to hide ul when I click outside it
I use useEffect with ref.current.contains(event.target) todo that with window.addEventListener("mousedown&...
0
votes
1
answer
31
views
Cannot get eCharts responsive feature to work
I have three carts in a table that I want to have auto resize if the window size changes, either by switching to a different size monitor or changing the browser size on the monitor.
According to the ...
0
votes
0
answers
16
views
Event Listeners only working on initial page, not on AJAX pagination reload
I have a loop grid which works and filters fine, with a dynamic pop-up box which appears when a container is clicked. My issue is that this only works on the initially loaded items in my grid, and ...
0
votes
0
answers
33
views
How do I use the mouseup event to control a game in JavaScript?
I'm trying to make a game in HTML5 canvas. For this, I created this control module with this function that adds listeners for keyboard and mouse inputs. However, the mouseup event is not working/...
-1
votes
1
answer
36
views
Can't add in DOM corret editable li element
I'm trying to create something like a to-do list. The structure of app is simple - I have one state for storing data of tasks and useEffect which add eventListners on every task. The task could be ...
1
vote
0
answers
66
views
JavaScript Event Listener Not Triggering on Search Input - keypress Event
I'm working on a stock market website called MyStok, and I'm trying to implement a search feature that listens for the Enter key press to trigger a search. However, the event listener is not firing, ...
-1
votes
0
answers
47
views
Vue error: Cannot read properties of null (reading 'addEventListener')
I am using the Chart.js library to build a bar chart. My app has a <select> with some elements inside. The chart is generated well. I added a zoom plugin which works fine the first time the ...
0
votes
3
answers
97
views
How to iterate a node-list in order to assign index-specific event-handlers to each element-node?
I'm trying to use a for loop to increment through multiple button elements so I can assign different actions to them.
I cannot figure this out, Here is the code.
I am very much new to javascript and I'...
0
votes
1
answer
55
views
addEventListner is not calling for First Time
const handleCharacterChange = (value,event) => {
const plainText = value.replace(/<\/?[^>]+(>|$)/g, '');
if (plainText?.length <= 250) {
...
-3
votes
1
answer
69
views
JavaScript how to log the value a user has put in? [closed]
The problem given was:
When the user clicks the button with the ID of generate-message, log the value the user has typed into the input field.
Here is the HTML provided:
<input type="text&...
0
votes
0
answers
26
views
Is it possible to add event listener to dependent field in form?
In Symfony, it's possible to add event listener on form field and then process the live value. This works perfectly, even in array of collections in form.
On the other hand, I've got dependent field ...
0
votes
1
answer
76
views
Unable to set State in React in UseEffect With 'popstate' eventListener
I have a useEffect in React. In this useEffect I have a popstate eventListener. This eventListener successfully triggers if I visit the page, then visit another page, then press back to go back to the ...
0
votes
0
answers
48
views
How do I add multiple eventListener scripts that don't listen to each other?
I am developing a rubric as a sort of pet project. The rubric contains two sections - one called
"Report Admin" and one called "Report Text". Each portion has three sub-sections ...
0
votes
1
answer
58
views
Why is the chat window opening before I click open chat?
So, initally, I had no issues. It seemed to be working fine. I load the script and it was giving just the 'open chat' option.
Now, it loads the whole chat window already open, but not the content ...
0
votes
0
answers
17
views
Triggering a Tracking Event from a MailChimp Embedded Form
I am trying to fire an event from an Amazon tracking pixel from a mailchimp embedded form as seen here:
<!-- Begin Mailchimp Signup Form -->
<link href="//cdn-images.mailchimp.com/...
1
vote
0
answers
7
views
loading the cards dynamically based on category when eventlistener click happens
i have been developing the restaurant menu website where i want to load the cards which has the image of the food its name, category and description. I need to load the cards dynamically based on ...
1
vote
1
answer
48
views
How to prevent text selection on double-click in JavaScript?
I'm working with a double-click event listener in JavaScript to trigger an action when a user double-clicks on certain text elements. However, I also have another event listener that responds to text ...
-2
votes
2
answers
71
views
Javascript addEventListener "click" issue. Click only works once [closed]
I want the image to change every time I click the img. But the click to change img only works once. What have I done wrong?
The random image picker is from this website: https://picsum.photos/ and ...
0
votes
0
answers
22
views
Drag Element from outside of iframe to inside of the iframe document in reactJS
// App.js
import React, { useEffect } from 'react';
const App = () => {
const handleDragStart = (e) => {
// Add custom data to the drag event
e.dataTransfer.setData('text/plain', '...
1
vote
4
answers
592
views
React Native - TypeError: window.addEventListener is not a function (it is undefined), js engine: hermes
I have an expo project, and setting up a clerk auth. I have followed all the required code clerk gave, and now getting this error on the links. Everything looks okay to me, but I cant figure out how ...
0
votes
0
answers
23
views
Event Listeners Not Working After Browser Back Navigation in Laravel Docker Project (bfcache Issue)
I'm working on a Laravel project that's running in a Dockerized environment with an Apache server. Everything works fine when I navigate the app normally. However, I run into issues when using the ...
-2
votes
2
answers
136
views
How to use event-delegation properly instead of adding a 2nd, concurring, event-listener for the same event-type?
I am using a document.addEventListener("DOMContentLoaded", function ()
to force the input pattern (first must be a letter, then prevent consecutive spaces, etc.)
Now I want to make a 2nd ...
0
votes
0
answers
16
views
Removing eventListener (function with an attribute) in JavaScript [duplicate]
I am working on selection mode in my app (selecting multiple elements to execute some action). It works like this: at default you have a list of elements (decks) which are <a> HTML elements. So, ...
1
vote
2
answers
40
views
How can I attach an addEventListener to an input field using the submit event?
I am making a simple tip calculator and first of all I am trying to save the value of the bill amount which the user can type into the input field (this input field has a type number attribute). There ...
0
votes
2
answers
65
views
JavaScript Broadcastchannel eventlistener not triggering when posting message
I have the following html file. When I open it the console only shows "BroadcastChannel created ..." and "Posting message to channel". Neither the eventlistener nor the onmessage ...
1
vote
2
answers
41
views
Vue3 event listeners cannot set properties of undefined
I've recently started using Vue3 after a couple year gap and have opted for the Composition API.
The issue I have is with the 2 event listeners in the onMounted function.
This is what I get for the ...
1
vote
2
answers
97
views
Adding and removing listeners in React Component
I'm trying to add and remove widow event listeners on opening and closing a component.
Issue is that isOpen in the handler is always at it's inital condition and doesn't use the latest state. How can ...
0
votes
0
answers
17
views
Javascript add event listner on Input if value change by other button [duplicate]
input event listener fires only when we type something in input, want to fire the event on click of button when values changes from outside
const currentValue = document.querySelector('#...
-2
votes
1
answer
76
views
In JS,Want to add event listener when mouse is moved anywhere, and the function is to display/hide content of the page
I want to add an event listener which, when user's mouse moves, will display the contents of the page for x seconds, then goes blank.
my guess will be to use onmousemove and whole page shall be the ...
2
votes
1
answer
42
views
Event-click React17 vs Event-click React18
If somebody knows please explain why does events in React18 work exactly like this?
I`v got component custom Select that should open its ul when click on it.To be more precise, when you click on ...
1
vote
1
answer
33
views
Global Variable is not being accesses in a particular block
I created a boolean variable at the top of my js code, It worked perfectly throughout the code and changes globally when its value changes in all Functions/Block where it is used. But in a particular ...
0
votes
1
answer
44
views
Is there a way to use replaceChildren() on looped elements when hovering over them?
const addToCartButtons = document.getElementsByClassName('add-to-cart');
const products = document.getElementsByClassName('product');
const addToCartButtonsArray = Array.from(addToCartButtons);
...
0
votes
0
answers
35
views
Event listener not being added to conditionally rendered element on load even when initial state is true
I'm having a problem (NextJS 12) attaching an event listener to an element that is conditionally rendered on load even though the initial state is true.
Basically, I have some buttons on a page that I'...
0
votes
0
answers
22
views
How to output variable values from addeventlistener [duplicate]
let xc = null;
let yc = null;
var el = document.getElementById("canvas");
el.addEventListener('mousemove', function(f) {
console.log('Coordinates: x=' + f.clientX + ' y=' + f.clientY);
...
0
votes
0
answers
67
views
OnClick EventListener not working in my code
I am trying to execute code when a button is pressed. I currently have the "catch all" alert set up.
My HTML code
<body style="overflow:hidden;" >
<div class="...
1
vote
0
answers
50
views
Can't remove event listener in React despite utilizing the useCallback hook
In my react app I prevent default touchmove behavior, but I'm unable to restore it.
I made sure to utilize the useCallback hook. I have confirmed through debugging that the removeEventListener method ...
2
votes
1
answer
76
views
useEffect not showing error for non existent event listener in cleanup
So as per documentation in React, the initial state of the below code of canMove is true. I changed it to false.
import React from "react";
import "./style.css";
import { useState, ...
0
votes
0
answers
27
views
beforeinstallprompt event not firing when using firebase in react app
I've a React app with a button to prompt users to install the PWA using the beforeinstallprompt event.
But when I add firebase to my project, the event stops firing. Removing firebase makes it work as ...
-1
votes
1
answer
22
views
Why does addEventListener not change the background color of the elements even though it is executed?
Why is it that when I move anotherSquare to square2 and click anotherSquare, the background color of square1 and square2 does not change even though console.log occurs?
const anotherSquare = document....
0
votes
4
answers
94
views
JS how to target a div inside of the clicked div
Kind of a special case of this: Change CSS of the clicked element.
If I have some divs like this:
<div class="parent">
<div class="child"></div>
&...
1
vote
1
answer
94
views
Change CSS of the clicked element
Probably a silly question, but the basic way I learned how to change CSS of something on click is
var x = document.getElementById("id");
x.style.height = "auto";
or whatever....
0
votes
3
answers
58
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
59
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
49
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
2
answers
62
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
67
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
49
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
47
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
51
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
34
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 ...