show selected text in textarea 26 26 activeelement

Solutions on MaxInterview for show selected text in textarea 26 26 activeelement by the best coders in the world

showing results for - "show selected text in textarea 26 26 activeelement"
Alessia
08 Jan 2021
1function onMouseUp(e) {
2  const activeTextarea = document.activeElement;
3  const selection = activeTextarea.value.substring(
4    activeTextarea.selectionStart, activeTextarea.selectionEnd
5  );
6
7  const outputElement = document.getElementById('output-element');
8  const outputText = document.getElementById('output-text');
9  outputElement.innerHTML = activeTextarea.id;
10  outputText.innerHTML = selection;
11}
12
13const textarea1 = document.getElementById('ta-example-one');
14const textarea2 = document.getElementById('ta-example-two');
15textarea1.addEventListener('mouseup', onMouseUp, false);
16textarea2.addEventListener('mouseup', onMouseUp, false);