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

  • SEARCH
  • Home
  • 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 8071309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:40:06+00:00 2026-06-05T13:40:06+00:00

For rendering SVG I’m using jQuery SVG plugin. And, now I want to add

  • 0

For rendering SVG I’m using jQuery SVG plugin. And, now I want to add text to each path and polygon. On jsFiddle you can see generated markup by plugin.

For creating text I wrote the following code:

var svgg = $("#rsr").svg('get');
var texts = svgg.createText();
svgg.textpath($("#Layer_x0020_1"),id, texts.string('We go ').
   span('up', { dy: -30, fill: 'red' }).span(',', { dy: 30 }).
   string(' then we go down, then up again'));

In the code on jsFiddle you can see that the textpath tag exists, but it’s not visible.
How to add text to the center of each path?
Thanks.

  • 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-05T13:40:07+00:00Added an answer on June 5, 2026 at 1:40 pm

    To place text in a straight line on top of a shape, in the middle of the boundingbox see:

    http://jsfiddle.net/dYuAA/114/

    It just adds some javascript to place text.

    function addText(p)
    {
        var t = document.createElementNS("http://www.w3.org/2000/svg", "text");
        var b = p.getBBox();
        t.setAttribute("transform", "translate(" + (b.x + b.width/2) + " " + (b.y + b.height/2) + ")");
        t.textContent = "a";
        t.setAttribute("fill", "red");
        t.setAttribute("font-size", "14");
        p.parentNode.insertBefore(t, p.nextSibling);
    }
    
    var paths = document.querySelectorAll("path");
    for (var p in paths)
    {
        addText(paths[p])
    }
    

    The above only looks at path elements, but you could tweak the selector to include whatever you need.

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

Sidebar

Related Questions

I've been using the jQuery.svg plugin to do some SVG rendering and it works
Using SVG path, we can draw 99.99% of a circle and it shows up,
I am using the .NET svg rendering engine to convert an svg file to
I'm looking for a way to deploy an Internet Explorer plugin for SVG-rendering without
I have a font in ttf file and want to generate SVG with text
I'm using the Raphaël Javascript lib (awesome stuff for SVG rendering, by the way)
I know it's not the jQuery SVG library causing this issue, but when rendering
I'm successfully rendering a polygon shaped window. However, I would like to outline it
I am getting rendering error inconsistently in JSF pages. I am using Trinidad Framework.
I'm working with jQuery to modify some svg files data on the fly... one

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.