我已忽略了该paste事件。我注意到,由于阻止了事件的默认行为,因此当前无法使用Ctrl + Z撤消“粘贴”。$(this).on('paste', function (evt) { // Get the pasted data via the Clipboard API. // evt.originalEvent must be used because this is jQuery, not pure JS. // https://stackoverflow.com/a/29831598 var clipboardData = evt.originalEvent.clipboardData || window.clipboardData; var pastedData = clipboardData.getData('text/plain'); // Trim the data and set the value. $(this).val($.trim(pastedData)); // Prevent the data from actually being pasted. evt.preventDefault();});有没有一种方法可以覆盖撤消功能,或者可以做其他不同的操作以使Ctrl + Z起作用?
添加回答
举报
0/150
提交
取消