I am trying to scrape a web page which includes multiple tabs. I want to get the quarterly data which is displayed when clicking on By-Quarter Tab, but my code keeps returning yearly data shown when clicking By-Year Tab. The problem is both types of data are on the same URL and when right-clicking “Inspect Element”, their IDs are also
Tag: getelementsbytagname
Error when trying to target and add classes to html, body, and __nuxt elements in Vue/Nuxt
I’m getting the error “cannot read property ‘classList’ of null” when trying to add/remove classes using document.getElementsByTagName(‘html’).classList, and also for any other high-level elements in the skies above Component Land, such as body or __nuxt. Running in mounted() lifecycle with nextTick function. Also tried checking process.client, but no luck either. Any ideas? Thanks : ) Answer From my comment above,
Use vanilla javascript to add / remove class to a different element after clicking on another one
I have looked through a number of similar questions but can not find a specific example of one that answers in vanilla JS how to add and remove a class to a different element from the one clicked on. I know it has something to do with setting up a loop and iterating through the elements, but I got lost