Мой код удаляет все теги html, кроме.
Мне нужно вставить обычный текст.
Мой HTM, куда я вставляю содержимое:
<p contenteditable="true">A high altitude hike which offers incredible views of Aconcagua (6958m) and Tupungato (6427m) in Argentina.</p>
Мой jQueryкод:
$('[contenteditable]').on('paste', function(e) {
e.preventDefault();
var text = '';
if (e.clipboardData || e.originalEvent.clipboardData) {
text = (e.originalEvent || e).clipboardData.getData('text/plain');
} else if (window.clipboardData) {
text = window.clipboardData.getData('Text');
}
if (document.queryCommandSupported('insertText')) {
document.execCommand('insertText', false, text);
} else {
document.execCommand('paste', false, text);
}
});
Мой jsFiddle:
https://jsfiddle.net/ovnx27pg/