I want to make a simple tool to replace the selected text for gaps/underscore. I already have that functionality, but I´d like to improve it, making the underscores be as many as the characters that the selected text has (including spaces).
It isn't a duplicate because the idea is to make it the same way the JSFiddle works; It has to take the selected text, and replace it there, like the JSFiddle.
Current JS:
$(document).ready(function() {
      $('#btn_convert_to_gaps').click(function() {
        document.execCommand('insertText', true, "________");
      });
    });<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <button id="btn_convert_to_gaps"><b>Convert selected to gaps</b>
    </button>
    <div id='fake_textarea' contenteditable>
      Select some text and click the button to make it bold...
      <br>Or write your own text
    </div>Example:
- "This sentence"
- I select "is se", and I expect:
- "Th_____ntence" (the same sentence with 5 underscores)
 
     
     
    