Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8515039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:02:03+00:00 2026-06-11T05:02:03+00:00

I need to load an existing SVG document in order to do some modifications:

  • 0

I need to load an existing SVG document in order to do some modifications: changing color and replace all circles by rectangles.

I read a lout about using javascript to access SVG nodes, or Raphael extension or jQuery SVG.

I decided to use jQuery SVG, because (in one of the documents I read there was written:) it’s not possible to change an existing, loaded SVG with Raphael. I’m not sure, if it is true.

On the other hand, some ware was written: jQuery SVG plugin is outdated?!

I’m not sure, if this is correct.

Right now, I use jQuery SVG plugin to load the SVG. The SVG consists of many circles, like this:

<svg version="1.1" width="" height="">
 <rect class="background" x="0" y="0" width="136" height="136" style="fill:white"/>
 <circle class="dot" cx="10" cy="10" r="2"/>
 <circle class="dot" cx="14" cy="10" r="2"/>
 <circle class="dot" cx="18" cy="10" r="2"/>
 <circle class="dot" cx="22" cy="10" r="2"/>
  [...]
 <style>
  .dot {fill:#000000;}
 </style>
</svg>

Now it should be possible:
1.) to change the color of all the circles by changing the class dot and
2.) replace all circles by rectangles.

To reach the first goal, I use svg.style(), like this:

mainSVG = $("#placehoplder").svg('get');
mainSVG.load(data, {addTo: true,  changeSize: false}); 
mainSVG.style('.dot {fill:'#f4a200'}');

This works, but it adds an additional style element/node to the SVG.

So the 1st question is: how to change/overwrite an exiting style element?

To reach the 2nd goal: I have no idea, how to handle this.

I have no idea, how to select SVG element in general. Using google, I still find the same stackoverflow questions again and again, which doesn’t help me. Also the jQuery SVG documentation is not helpful at my point of knowledge. (because basics are missing)

For example this simple test to change the radius of all circles does not work.

allCircles=$('*[class~="dot"]');
mainSVG.change(allCircles,{r:10});

So the 2nd Question is:
How to select a group of SVG elements (by class or element-type) in order to change them (or may i have to iterate trough?)?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:02:05+00:00Added an answer on June 11, 2026 at 5:02 am

    After searching the web for e while, i decided to choose the following solution:

    So the 1st question is: how to change/overwrite an exiting style element?

    Changing an exiting style element is difficult, like changing an HTML style element with JS.
    I choose the following way (because it looks like the best alternative). Finaly it’s removing the old style and adding a new:

    1. creating SVG on serverside with no style tag
    2. define an default style as an javascript object
      svgStyle = {'.dot':{'fill':'white'}}
    3. creating an method to transform the svgStyle into HTML source, which return mySvgStyle=' .dot {fill:white}
    4. Loading the SVG and apply the style Element to the SVG
      mainSVG.style(mySvgStyle);

    And now: all the time, i like to change the SVG style, i remove the old style SVG element $('style', mainSVG.root()).remove();, modify the svgStyle JS object (adding or remove properties) and creating the new SVG style tag (see #3 and #4 in the listing above)

    How to select a group of SVG elements (by class or element-type) in order to change them (or may i have to iterate trough?)?

    It looks like, an iteration is the onliest way. jQuerySVG plugin seams not possible to handle group of DOM (SVG) elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to load some arbitrary HTML into an existing DOMDocument tree. Previous answers
I need to load a model, existing of +/- 20 tables from the database
I need to load an XML source using Simple XML, duplicate an existing node
We've setup some different load tests and need to generate/send the result pr. e-mail,
I've a trivial question. I need to load an existing file into JEditorPane using
I need to quickly wrap some security around an existing ASP.Net 2.0 web app.
I need to load a Model in a component to save the Data of
I need to Load RVM into a shell session as a function , so
I need to load a custom function from an extern file but without causing
I need to load data into my treestore. My ajax request give me XML

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.