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);