Must a svg be inline to query one of its nodes with javascript?

Viewed 34

I usually put the svg I want to animate using javascript inline, or I cant get one of its node, whether it is by id or class, or using jquery or vanilla JS.

Is there a way to query an SVG node if it is not inline?

With an object, I can't get it to work.

  <object type="image/svg+xml" data="/assets/images/logo.svg"> 
    <img src="/assets/images/logo.png" alt="">
  </object>

My javascript file is called at the end of the body node and I wrapped my code in a $(document).ready() function.


EDIT: the svg dom nodes are indeed in the page code, but when I try a console.log(document.getElementById("item_id")) it doesn't return anything, both on Chrome and Firefox, with ubuntu.

1 Answers
Related