Я думаю, вы хотите заменить все "," внутри div.так что вы можете сделать это следующим образом: получите html внутри div, затем замените все ','
function replaceComma(){
$('#divWithComma').html($('#divWithComma').html().replace(",",""));
console.log('replaced the comma, if you want to see hiding the comma please run the snippet again');
}
function hideComma(){
let text = $('#divWithComma').html();
let stringArray = text.split(',');
let finalHtml = "";
for(let i = 0; i<stringArray.length-1; i++){
finalHtml += stringArray[i] + '<span style="display:none;aria-hidden=true">,</span><p></p>';
}
$('#divWithComma').html(finalHtml);
console.log("yes hide the comma");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='divWithComma'>
<p>,</p>
<input type='button' onclick='replaceComma()' value='replace comma' />
<input type='button' onclick='hideComma()' value='hide comma' />
</div>