Paste plain text on contenteditable element

1.62K views
no comments
7 Sep 2014 10:24 am

Its a great feature of #html5 to paste a text data into a element with contenteditable attribute, but when you copy data its copy the rich text with format after paste of content its looks ugly in element, so here code its won’t make ugly pasted content.

$('*[contenteditable]').on('paste',function(evnt) {
	evnt.preventDefault();
	var plain_text = (evnt.originalEvent || evnt).clipboardData.getData('text/plain');
	if(typeof plain_text!==’undefined’){
		document.execCommand('insertText', false, plain_text);
	}
});

NOTE:Your Email Address will be not shown and please do not add spamming comments because here is REL="NOFOLLOW" on your links and comments also moderated shown.
<code>Put html css or any language code under this tag</code>