Guys when I try to replace some value in input text box, its replacing only first value and its not replacing entire conversation.
In Input Text box I have conversation looks like
User 1 Prefix_ago User 2 Prefix_ago User 1 Prefix_ago
I wants to replace only prefix_ago with :
function copy() {
var text = document.getElementById('result1').value;
document.getElementById('id1').innerHTML = text;
$('#id1').each(function() {
var text = $(this).text();
$(this).text(text.replace('prefix_ago', ' : '));
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea class="result" id="result1" rows="10" cols="150" style="font-size:11px;resize: none; width:225px;"></textarea>
<button class="btn58" id="btn" onClick="copy()"> Copy & Replace</button>
<div id="id1">
</div>
I have value called Prefix_ago
which is repeating multiple times in my paragraph I want replace that to colon " : " that code is working but its replacing only very first value not entire paragraph