Skip to content

Lit-html target a DOM node

Imagine I have a template with a button and a spinner next to it. How can I tell the spinner to show up when the button is pressed? I want to be able in ‘handleClick’ to target this specific spinner and not some other in the page (there might be many we don’t know). In react we can use refs.

Why currentTarget value is null

I am learing event.target and event.currentTarget. I think i am clear with the difference between the two. But stuck in a situation where event.currentTarget value turns out to be null. Following are the HTML and JS code snippets: HTML code JavaScript Code My doubt is that in line1 and line3 I got the value o…

React – how to display all products using dropdown?

First time trying to do this so please bear with me. I’m using a dropdown to filter product data from a local JSON file based on category. The code below does filter and display the products based on category when a user selects a category. However I’d like to show all of the products on load befo…

Reducer function for a nested array with conditions

I’m struggling to write a reducer function for the nested object that I have. queryResult can have many Parents. Every Parent has items, and every item has subitems with their .ids. How to write a reducer that would reduce the queryResult by taking in the parentId and the itemId and returning the array …

Puppeter delete node inside element

I want to scrape a page with some news inside. Here it’s an HTML simplified version of what I have : I want to get the author and text body of each news, without the blockquote part. So I wrote this code : It works well, but I don’t know how to remove the blockquote part of the “news-body&#8…