Category "dom"

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

How to add items from object in DOM with button click in javascript?

first time posting in here :) I have recently started coding and for JS study practice, I wanted to make a button in my navbar that generates an object to DOM a

Add new tag to the middle of element

I am trying to surround specific words in textContent with HTML tags, this could hypothetically be done by doing element.textContent = element.textContent.repla

Add new tag to the middle of element

I am trying to surround specific words in textContent with HTML tags, this could hypothetically be done by doing element.textContent = element.textContent.repla

How can i get Y position in all the website page

I have a website which is 6 viewports height. I would like to get the Y position for no matter where i am in the page not only the viewport. I have tried : eve

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