Category "dom"

How do I use variable in a query selector - js?

What am I doing wrong? there are 7 pictures with pre-made IDs from "img1" to "img7" function changeWidth() { let b = 50 let k = 0

How to use the visibilitychange event to display messages when tab is hidden?

When an customer opens a new tab or goes away from the current sites tab, I'm trying to insert an promo message in the tab of a browser that flashes back and fo

How do you test a form upon the submission addEventListener with jest without a framework only vanilla JS

Most of the research I have done in regards to jest testing unit testing and/or integration testing is all heavily geared towards React. But I am not using reac

Why does jQuery or a DOM method such as getElementById not find the element?

What are the possible reasons for document.getElementById, $("#id") or any other DOM method / jQuery selector not finding the elements? Example problems include

event listener's event is being used more than once

I have this weird bug that whenever I want to add an item/card to the list and I cycle between clicking the text input and then clicking outside of it, the list

Firefox extension DOM change weird behaviour

It's my first time trying to learn Firefox extension development. To get started, I'm trying to make a simple extension that alters some parts of the youtube.co

Why does Attr inherit from Node in the DOM?

according to the DOM Core, Attr objects inherit the Node interface, but since they are not actually child nodes of the element they describe, the DOM does not

Hiding DOM elements with a chrome extension without causing a flicker

Preface: I am aware that there is a duplicate question out there. I am posting it again because it has no answers (and it's from 4 years ago). General descripti

performing a search on enter?

I have this form: <form> <label for="locationsearch">Location:</label> <input type="search" id="locationsearch" name="locationsearch" /

In Event Propogation, how does the event know when to fire?

In the following code: <div onClick={() => console.log('outer div')}> <div onClick={() => console.log('middle div')}> <div onClick={(

Add a function on focus and remove it on blur

I'm trying to set a simple script where, whenever you focus on an input and press Enter, something happens. Just like in those searchboxes on webpages and forum

Make persistent changes to HTML file using JavaScript [duplicate]

The code below saves the contents of a <textarea> to the DOM when the Save button is clicked. function save() { // Create the new el

DOM Exception quota exceeded indexdb - error handling

We are using indexedDB to store files locally. We have an issue when the browser is running out of space (reaching the available quota). It seems that the trans

How can I check if an element still exists in the DOM?

How can I check if an element still exists in the DOM? <div id="parent"> ... <div class="my-class"></div> </div> let parent = docum

Certain DOM Manipulation doesn't work with passport js

I realised when I am not logged in on my website certain DOM elements don't work. I am using passport-local implement auth on my website. For example when I pre

Getting a NodeList of the HTML tags in Mithril

Is there a way of having a NodeList of the HTML tags in Mithril? I need to get the width of the blocks. Something like that on vanilla js: const blocks = Array.

Is there a way that an event listener function could execute although there's an if statement preventing it from doing so?

I've been trying to make this work but I can't seem to figure out where the problem is coming from or what's producing it. The script randomly executes parts of

How to append "delete button" to EVERY list item that is newly created in JS?

Shopping List exercise using JS DOM. My full code: https://codepen.io/lil_a/pen/BaQKvqZ?editors=0110 I have to add a new "Delete" button to every newly created

Javascript adding a new event listener on local object

I have a script below, where I dynamically create an Element Node of type 'li'. This addMovieHandler() is called whenever the user clicks on a button. Additiona

How to get querySelectorAll from another webpage?

I'm trying to get data from another webpage, using the HTML DOM. I tried code from another StackOverflow question (querySelectorAll() to html from another page)