$("div[contenteditable=true]").off('paste').on('paste', function(e) { e.preventDefault(); var text = e.originalEvent.clipboardData ? e.originalEvent.clipboardData.getData('text/plain') : window.clipboardData.getData('Text'); _insertText(text);});function _insertText(text) { // use insertText command if supported if (document.queryCommandSupported('insertText')) { document.execCommand('insertText', false, text); } // or insert the text content at the caret's current position // replacing eventually selected content else { var range = document.getSelection().getRangeAt(0); range.deleteContents(); var textNode = document.createTextNode(text); range.insertNode(textNode); range.selectNodeContents(textNode); range.collapse(false); var selection = window.getSelection(); selection.removeAllRanges(); selection.addRange(range); }};