0

I'm trying to change fill color on my SVG file. But no one from methods is working. I was trying a lot of, but I can't even get object which I want to.

<object type="image/svg+xml" data="map.svg" height="500" id="world_map">
    Your browser does not support SVG.
    <script src="draw.js"></script>
</object>

This is my SVG declaration and script src.

And script is

var x = $('#world_map#path1622');
console.log(x);

But it is not working. It isn't even return the good element. I've tried code with it but it's not working too.

BillyB
  • 1
  • 3
  • Your jQuery is invalid; you're probably looking for a space before `#path1622`. You also don't appear to have jQuery defined. – Obsidian Age Aug 17 '17 at 23:58
  • Its not this. Ive just made my code shorter,and posted most important things. I've had var x = $('#path1622'); before and i've had same problem. It cannot get to this path And i don't have error. Its finding #path1622 but when i check this object propeties there is no css,no id and other things,which are in svg code – BillyB Aug 18 '17 at 00:09
  • Your svg document is a framed element, to access it, you need to request the framed document from the `` element's `contentDocument`. – Kaiido Aug 18 '17 at 00:34
  • 1
    Possible duplicate of [JavaScript accessing inner DOM of SVG](https://stackoverflow.com/questions/11434916/javascript-accessing-inner-dom-of-svg) – Kaiido Aug 18 '17 at 00:38
  • Still not working and didnt find anwser. $(window).bind('load',function() { var mySvgObject = $('#objectid'); console.log(mySvgObject); $('object#objectid#id_of_element').style("fill", "white");; }) Even with $(mySvgObject).find('#elementid').style("fill", "white"); – BillyB Aug 18 '17 at 09:53
  • The thing i try to color is – BillyB Aug 18 '17 at 10:00
  • My svg is svg/xml does it matters? – BillyB Aug 18 '17 at 10:10

1 Answers1

-1

I think i have a tip. My svg file is like -Object -#document -svg

And i have to to the code like

var content = $("").contents();

I have to make access to the document,object or svg?

BillyB
  • 1
  • 3