我已忽略了該paste事件。我注意到,由于阻止了事件的默認(rèn)行為,因此當(dāng)前無(wú)法使用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();});有沒(méi)有一種方法可以覆蓋撤消功能,或者可以做其他不同的操作以使Ctrl + Z起作用?
撤消JS中的覆蓋粘貼
慕哥6287543
2021-04-30 14:15:09