0

Here is my appended svg text:

$("#textinArea").append(parseSVG('<text x="' + xtext + '" y="' + ytext + '" id="' + '#text_chaise_' + i + '_' + j + '" font-size="55" data-access="'+access+'" font-family="Verdana" alignment-baseline="middle" text-anchor="middle" fill="Black">O</text>'));

After that i wanted to delete this text and clear it from the image/rectangle.

I tried many solutions like :

- $("#text_chaise_" + i + "_" + j).empty();              

- $("#textinArea").append(parseSVG('<text x="' + xtext + '" y="' + ytext + '" id="' + '#text_chaise_' + i + '_' + j + '" font-size="55" font-family="Verdana" alignment-baseline="middle" text-anchor="middle" fill="Black"></text>'));

- $("#textinArea").closest("text_chaise_" + i + "_" + j).empty();

and i've got no solution to delete this .

whene i use : $("#textinArea").empty() it deletes all the texts that are appended to textinArea and its not what I want.

Innat
  • 16,113
  • 6
  • 53
  • 101
  • Have you tried this: https://stackoverflow.com/questions/12588260/how-to-remove-an-appended-element-with-jquery-and-why-bind-or-live-is-causing-el and also this might help https://stackoverflow.com/questions/9888774/deleting-the-appended-data-jquery – A. Meshu May 21 '18 at 17:38

1 Answers1

0

Maybe you could try it as a by-reference object?

var myText = parseSVG('<text x="' + xtext + '" y="' + ytext + '" id="' + '#text_chaise_' + i + '_' + j + '" font-size="55" data-access="'+access+'" font-family="Verdana" alignment-baseline="middle" text-anchor="middle" fill="Black">O</text>');
$("#textinArea").append(myText);

// Delete it by reference
delete myText;

A delete will delete any dom elements, and maybe this will also work on svg elements. But I'm not sure.

Leroy
  • 1,600
  • 13
  • 23