I want to remove a text at the end of each paragraph.
Dispongo del 1ero boton: anadir (añade un texto al final de cada parrafo) --> OK
Dispongo del 2ndo boton: quitar (quita el texto al final de cada parrafo) --> ¿?
What would be the possibility of removing what I previously added? Passing the same text that I added?
Code jQuery :
//Añadir texto al final de cada parrafo.
$("#anadir").click(function(){
$("p").append("<strong> Hola </strong>");
});
//Quitar texto al final de cada parrafo.
$("#quitar").click(function(){
$("p").remove(":contains('Hola')"); /// .substr(-4);
});
I will explain myself better: I have X I have with 4 paragraphs, by clicking "Add" I add "Hello" at the end of each paragraph, I click again "Add" and add "Hello" at the end of each paragraph. If I click "Remove" later, I would have to delete the last "Hello" (.substr (-4)), right? but if I pulse more than 2 times "Remove", I can not delete more text than it is predefined. If I pulse more times "Remove" than "Add" there could be the problem, I must control that.