Adsense
Popular Posts
- Install APXS in Redhat Linux
- MySQL workbench -"Could not decrypt password cache"
- Transfer modules between sites
- JavaScript, remove trailing insignificant zeros after toFixed function
- Set Windows path command line
- datatable order by nunmeric
- MySQL date created and date modified
- super(props) in React
- PHP, dump varailbes in a format way
- React: connect(mapStateToProps, mapDispatchToProps)
Friday, November 23, 2018
JS/JQuery: paste the plain text only
When I copy the Word document to the text box,
in background a lot html codes and strange characters from Word
are saved.
Below is the JS/JQuery code to paste the plain text ( I have a text box with class comment):
function clickcomments($td){
$td.find('.comment').on('paste', function(event){
event.preventDefault();
var text = (event.originalEvent || event).clipboardData.getData('text/plain') || prompt('Paste something..');
window.document.execCommand('insertText', false, text);
$(this).html($(this).html().replace(/<div>/g, '<br>').replace(/<\/div>/g, '<br>'));
});
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment