Why
var offer=document. getElementById( "editor_display ing_text").valu e;
returns undefined?
Thank You
var offer=document. getElementById( "editor_display ing_text").valu e;
returns undefined?
Thank You
function makeBold(txt){
var offer=document.getElementById("editor_displaying_text").value;
offer=offer+'\n' ;
offer=offer.replace(txt,'<b>'+ txt +'</b>');
document.getElementById("editor_displaying_text").value = offer;
}
<script language = "JavaScript">
function getSelectedText(){
var txt = '';
if (document.getSelection) txt = document.getSelection();
else if (document.selection) txt = document.selection.createRange().text;
return txt;
}
function makeBold(txt){
var offer=document.getElementById("editor_displaying_text").value;
document.write(offer);
offer=offer+'\n' ;
offer=offer.replace(txt,'<b>'+ txt +'</b>');
document.getElementById("editor_displaying_text").value = offer;
}
</script>
</HEAD>
<BODY>
<form name="editor">
<input type="button" name="bold" class="editor_bold" onClick="makeBold(getSelectedText())">
<input type="button" name="unordered_list" class="editor_unordered_list">
<input type="button" name="anchor" class="editor_anchor">
</form>
<div id="editor_displaying_text" contenteditable="true" indicateeditable="true"></div>
Comment