How do I remove selected text in javascript?
Thank You
Thank You
function getSelectedText(){
var txt = '';
if (document.getSelection) txt = document.getSelection();
else if (document.selection) txt = document.selection.createRange().text;
return txt;
}
function makeUnorderedList(txt){
var tempText="";
var textToRemove="";
var splitResult = txt.split('\n');
var offer=document.getElementById("editor_displaying_text").innerHTML;
offer=offer.replace(txt,''); ,<---this doesnt work
for(i = 0; i < splitResult.length; i++){
tempText=splitResult[i];
tempText=tempText.replace(splitResult[i],'<li>'+splitResult[i]+'</li>');
textToRemove+=tempText;
offer+=tempText;
}
offer=offer.replace(textToRemove,'<ul>'+textToRemove+'</ul>');
document.getElementById("editor_displaying_text").innerHTML = offer;
}
Comment