<p>Some text to copy and paste.</p>
<input type="text" />
<p class="result"></p>InputEvent: data property / notebook
InputEvent: data property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const editable = document.querySelector("input");
const result = document.querySelector(".result");
editable.addEventListener("input", (e) => {
result.textContent = `Inputted text: ${e.data}`;
});