We get the pasted text with: e.clipboardData.getData('text/plain') Then we can write the following JavaScript code to listen to the paste event: const handlePaste = (e) => const div = document.getElementById('editableDiv') div.addEventListener('paste', handlePaste) Therefore, we can just listen to that event when our own event listener to get the pasted content.įor instance, we can write the following HTML: Paste The paste event is triggered when we paste data into an element. In this article, we’ll look at how to get clipboard data when we paste it into our JavaScript app.
Sometimes, we may want to get the clipboard data that we paste into an element in our web app.