我需要在标准操作完成后执行一些操作。与 event.preventDefault()
这是我需要的示例:
$contentEditable.on('paste', function (event) {
event.doWhatYouNeedToDo();
// here I will use `range` object to grab cursor position
// and take some additional actions with inserted text
});
以下是事件如何工作的示例:https://jsfiddle.net/5emcf8rw/
执行标准操作(文本更改)后,我需要在某个地方处理新文本
这是@A建议的解决方案。沃尔夫
$contentEditable.on('paste', function (event) {
setTimeout(function () {
// do whatever you want here
}.bind(this), 0);
});
我们能否确定标准操作完成后会触发超时函数?
最佳答案
您可以使用超时稍微延迟一下:
$contentEditable.on('paste', function (event) {
setTimeout(function () {
// do whatever you want here
}.bind(this), 0);
});
关于javascript - 标准事件操作完成后采取行动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31725264/