I have a code which bold the complete text present in textarea but i want to Bold only selected text to be bold present in text area. Note that i don't want the text to be in Div tags. I want to do the same with text area only. here is my code:
<form action="index.html" name="theform">
<input type="button" onclick="setClass('');" value="Normal" />
<input type="button" onclick="setClass('italics');" value="Italics" />
<input type="button" onclick="setClass('bolded');" value="Bold" />
<textarea id="txt">This is some text in our textarea</textarea>
and here is my javascript code
<script type="text/javaScript">
function setClass(class_name) {
document.getElementById('txt').className = class_name;
}
</script>
above code bold the complete text but not the selected text