0

我正在尝试将粘贴事件绑定到我的 jquery 文本编辑器,以便我可以粘贴为纯文本。我已将第二行添加到我的jquery-te-1.4.0.js.

editor.attr("contenteditable","true").html(thisElementVal);
editor.attr("onPaste","$(this).bind('paste', function (e) { e.preventDefault(); var text = e.clipboardData.getData('text/plain'); console.log(text) });").html(thisElementVal);

由于某种原因,输出给出,

Uncaught TypeError: Cannot read property 'getData' of undefined

有人可以帮帮我吗?谢谢。+

4

1 回答 1

0

显然var text = e.originalEvent.clipboardData.getData('Text');使它起作用了。

于 2016-01-04T15:14:35.390 回答