0

I am working on the below code. Is it doable to append a text into path using jQuery?

$("path").each(function() {
  $(this).append("<span>Title</span>");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<svg height="210" width="400">
  <path d="M150 0 L75 200 L225 200 Z" fill="gold"/>
</svg>

<svg height="210" width="400">
  <path d="M150 0 L75 200 L225 200 Z" fill="gold"/>
</svg>
halfer
  • 19,824
  • 17
  • 99
  • 186
Behseini
  • 6,066
  • 23
  • 78
  • 125
  • 1
    I see a big yellow triangle. Where do you want the text? – react_or_angluar Oct 24 '20 at 01:38
  • like in the center of each path – Behseini Oct 24 '20 at 02:11
  • Horizontal paths? What size text? Measured in pixels? What font? I see a 2nd yellow triangle when I scroll down. – react_or_angluar Oct 24 '20 at 02:17
  • Aside: I notice that a large number of your questions are formulated thus: _Can you please take a look at this [code|demo] and please let me know [problem statement]_. It's a bit fluffy, and readers may think that it has a needy, pleading feel. It may be why you are getting downvotes - your questions are imploring readers about all the actions you'd like them to take, in order to alleviate your well-advertised suffering. You may have a better response if you explain what actions _you_ will do - and that is probably appropriate, given that it is your code. – halfer Nov 17 '20 at 21:59
  • So, you can instead use more "I statements". For example, "I am working on the demo code below. How can I append a string to a path using jQuery?" Readers will see that you understand that the bulk of the work is yours to do, and thus will be more likely to help you. I acknowledge that you may not be trying to dump your work onto volunteers - the trick is to also sound like you are not doing that. – halfer Nov 17 '20 at 22:01

0 Answers0