title: Change Font Style of selected text in javascript
body: <p>I am using javascript without any library. Now I want to  change font style of selected text only of text area. I have extracted the select text using following function.  Can anyone help??    </p>
  
  <pre><code>function ShowSelectionInsideTextarea(editor){
  
    var textComponent = document.getElementById(editor);
    var selectedText;
    // IE version
    if (document.selection != undefined)
    {
      textComponent.focus();
      var sel = document.selection.createRange();
      selectedText = sel.text;
    }
    // Mozilla version
    else if (textComponent.selectionStart != undefined)
    {
      var startPos = textComponent.selectionStart;
      var endPos = textComponent.selectionEnd;
      selectedText = textComponent.value.substring(startPos, endPos)
    }
  
      console.log(selectedText);
  }
  </code></pre>