Posts

Showing posts with the label dom

forEach does not access all elements in NodeList

forEach does not access all elements in NodeList Since the forEach array method can now be called on a NodeList . I was wondering why if you make changes to the content of a childNodes NodeList while looping with forEach , forEach does not detect the changes. forEach NodeList childNodes forEach forEach grid.childNodes.forEach(function(tableRow, index, nodeList) { tableRow.remove(); }); Here, i'm trying to loop through my table(grid) elements children and remove each children( tableRow ) from the table. However, forEach never completely loop over every element, always leaving out one last tableRow to be remove d.I think it has something to do with the childNodes NodeList being live, and the forEach not being able to properly follow it or something. tableRow forEach tableRow remove What’s your relevant html? What’s the selector for grid ? – David Thomas 6 mins ago ...

Could not find elementById on mat-card-content

Could not find elementById on mat-card-content Having a canvas on the page is no problem to find it by id: <canvas id="chart" width="400" height="400"></canvas> document.getElementById("chart") everything fine. but if i wrap it in a mat-card i could not find it anymore: <mat-card> <mat-card-title>My title</mat-card-title> <mat-card-subtitle>My sub title</mat-card-subtitle> <mat-card-content> <canvas id="chart" width="400" height="400"></canvas> </mat-card-content> </mat-card> and this results with: document.getElementById("chart") null any idea why? any errors in console? can you please add a Minimal, Complete, and Verifiable example to your question? – ochi Jul 1 at 21:34 ...

Web scrapping of masked URL using VBA

Image
Web scrapping of masked URL using VBA I want to scrape some stock data from a website https://dps.psx.com.pk/ using VBA in Excel, but the problem is the URL of this website does not change. When I click on market summary as highlighted in the below image that will return the whole market summary, I just need to scrape data in Excel using VBA as highlighted in the following image: Did you look at the requests being made when you search for "EFOODS"? – antfuentes87 Jul 1 at 16:30 This is basic web scraping. You need to inspect the source code elements and like @antfuentes87 says , follow the requests. It sounds more like you need to purchase a third party tool to help you. It's also called "scrape" and "scraping" – dbmitch Jul 1 at 16:44 ...

Get partial class name and text inside div using regex

Get partial class name and text inside div using regex I need to get two values from this HTML, which is either an error or a success from toast-* , and also get the value inside the toast-message : toast-* toast-message <div class="toast toast-error" style=""> <div class="toast-message">You have failed.</div> </div> <div class="toast toast-success" style=""> <div class="toast-message">You have succeed. </div> The div elements only show once at a single time, which can be either error or success. div Is there any way I can use regex, so I can extract the value within array so it either: ['success', 'You have succeed.'] or ['error', 'You have failed.'] Any help would be greatly appreciated. Thanks! Why do you want to use a regular expression here? Do you have a reference to the elements? – CertainP...

How to get 8 columns per row? [Javascript , Bootstrap]

Image
How to get 8 columns per row? [Javascript , Bootstrap] So i am here wrote this simple function for searching movies and manipulating them in the dom.and the problem here is when a movie name is typed the api response back with at least 20/30 recommendations.And i want the fetched data to be distributed in 8 columns per row.So i wrote this function : Javascript part : db.multisearch() .then(data=>{ var div=document.getElementById('call'); var output=''; for(let i=0;i<data.length;i++){ var poster=data[i].poster_path; var title=data[i].title; for(let j=0;j<=8;j++){ output +=`<div class="col-sm"> <div class="card mb-3"> <img class="card-img-top" src='https://image.tmdb.org/t/p/w342//${poster}' alt="Card image cap"> <div class="text-block"><p>${title}</p></div> </div> </div>`; } } div.innerHTML=output; }); HT...