Question

How do I get all the DIVs starting with ID div-gpt-ad?

This is the line

document.querySelectorAll('div#div-gpt-ad-1363287890054-0-oop');

there are multiple divs with IDs starting with div-gpt-ad on my page and I want to get them all.

Was it helpful?

Solution

document.querySelectorAll('div[id^=div-gpt-ad]');

This will get all div tags with an id starting with div-gpt-ad.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top