453
questions
0
votes
0
answers
34
views
Targeting child nodes of a query selector all loop [duplicate]
I have a series of repeating HTML blocks on a page (over 200 times) that need to have some content tweaks made via some simple javascript. What I've done is use querySelectorAll to target all of the ...
0
votes
1
answer
94
views
How to use sibling combinator together with `:scope` in `querySelector`
Let's say I have an element and I want to select the next matching sibling. Normally, in css I'd be able to write <some selector for this element> ~ <selector for sibling>, but the sibling ...
1
vote
4
answers
89
views
Use wildcards to trace an a.href in the querySelectorAll NodeList
Let's say that instead of looking at the ID, I want to select all a.href elements that contain (a piece of) this example: if document.url is "www.youtube.com".
var youtubeID = document....
1
vote
4
answers
72
views
looking for a smarter way to go though querySelectorAll nodelist (in GTM)
Tried a lot of solutions (like these https://dev.to/dailydevtips1/javascript-loop-queryselectorall-results-j6) but can't get the loop to work in GTM/Google Tag Manager.
My working script - not very ...
0
votes
1
answer
32
views
javascript - querySelectorAll with addEventListener - how to get number of interacted element and variable from variable
I have HTML:
<form name="form" ..
<input type="text" name="title1" id="title1" class="f_title" value="smth LV">
<input type=&...
-2
votes
5
answers
93
views
How to perform this dynamic Find and replace in Javascript over user generated data?
I have an app that allows user to generate text with HTML code in the following format:
<h2>User generated Dynamic Data 1</h2>
<h3>User generated text 1.1</h3>
<h3&...
-1
votes
2
answers
147
views
How to efficiently / correctly handle the click-event at any list-item of a multiple nested list-based menu / navigation?
Sorry if my question is really for newbie level...
I have a 3 level list to build a menu, but I don't want to use href.
I would like to use a specific attribute instead and call a javascript function ...
0
votes
0
answers
207
views
MutationObserver in Tampermonkey script always misses the first node
I have the following Tampermonkey custom script:
// ==UserScript==
// @name Hacker News
// @namespace https://news.ycombinator.com/*
// @version 2024-02-02
// @description try to take ...
1
vote
1
answer
131
views
Use previously cached selectors with querySelector()
How can I use previously cached selectors with certain aspects of querySelector() ?
For example, I have this HTML / JavaScript:
let L1, L2, L3;
L1 = document.querySelector('#L1');
L2 = L1....
0
votes
0
answers
21
views
Blur Container with all seeMore button
Am coding web interface that allow user to clic some content to expand it and see more détails.
Here My Js code
Const seeMoreBtn = document.querySelectorAll('seeMoteBtn');
For(let i=0; i<...
0
votes
2
answers
76
views
Stop next event listener from firing when one type of event is handled
I have 2 click listeners set up, these handle showing a modal and removing a note. These listeners use event delegation and is set up on parent container. The Note is rendered afters when users inputs ...
0
votes
0
answers
24
views
Can't render my items in to my html file with javascript
HI everyone i'am having a issue in javascript I have to files in html and use one javascript for both but i'am getting this issue that it says selectors.cartItems: null
here's my code:
const ...
1
vote
4
answers
172
views
How to create unobstrusive JavasScript when there are hundreds of entries
I read about unobstrusive JavaScript and how Javascript should be not explicitly placed inside HTML code.
Fine! But I have these hundreds of search results where I placed click events in the HTML ...
0
votes
1
answer
71
views
How to debug "not a valid selector" without access to the offending browser page
I made a TamperScript at work (in Chrome) that gathers a list of elements from a webpage. The script is used by many people without errors. But on one person's workstation it fails with the error:
...
-1
votes
1
answer
115
views
querySelectorAll is not returning updated nodelist inside a recursive function
I am trying to grab an element in the DOM that is created in the future. To simplify, When the user uploads an image by clicking on an upload button, a div is created in the DOM, which has a class ...