I tried ( jsfiddle ) but it does not work.
As you can see, the warning is empty. It as a function .val () is launched before copying a string.
$(document).on('paste', '#pasteIt', function(){
alert($("#pasteIt").val());
var withoutSpaces = $("#pasteIt").val();
withoutSpaces = withoutSpaces.replace(/\s+/g, '');
$("#pasteIt").text(withoutSpaces);
});
Why?
source
share