I need to display a div inside text area below selected text.
Javascript:
function getSel() {
var txtarea = document.getElementById("mytextarea");
var start = txtarea.selectionStart;
var finish = txtarea.selectionEnd;
var allText = txtarea.value;
var sel = "****";
var newText =
allText.substring(0, start) + sel + allText.substring(finish, allText.length);
txtarea.value = newText;
}
$(document).ready(function () {
$('#newpost').hide();
$('#mytextarea').on('select', function () {
$('#newpost').show();
});
});
Here is my plunker
my requirement is to replace the text with stars,on selection of text in textarea the div with "***" must be shown below the selected text and after clicking on stars the text must be replaced with stars and div must be hidden utill the text is selected.
Thanks in Advance.