I am trying to access <g>
tag from SVG by class name (ads
) and which is rendered using JavaScript into <object>
tag of HTML.
SVG is rendered here
<object id="container2" type="type=" image/svg+xml"></object>
Using Javascript
player2 = lottie.loadAnimation({
container: document.getElementById('container2'),
renderer: 'svg',
loop: false,
autoplay: true,
path: 'assets/mindmap2.json'
});
But the issue is When this function called, it gets <g>
but in the console, it shows the zero elements inside the HTMLCollection.
window.addEventListener("load", () => {
console.log(document.getElementsByClassName('ads'));
});
Microsoft Edge Console Log