I have a div which I am appending text to. I can remove the text from the div but it removes all the text. I only want to remove specific text and keep the other text. As this is dynamic, so I will not be able to use id's or classes for the text.
I have tried searching for the text using the following.
$('#test-div:contains("'+test2+'")').text('');
var test1 = 'Hello World!';
var test2 = 'Good bye World';
$('#test-div').append(test1 +' '+ test2);
$('#test-div:contains("'+test2+'")').text('');
<div id = "test-div"></div>
It should just remove the variable text but removes it all. I would like it to remove just that variable text. I have googled to try and find a solution but I was unable to find a solution.