我在我的项目中使用了JQuery,唯一使用它的代码行如下:
$('#div').on('input', function() { ... });
有没有更轻量级的lib/polyfill可以替代,它允许在可内容编辑的div上注册输入事件?
发布于 2017-08-05 10:30:02
在纯javascript中,你可以这样做:
document
.getElementsByTagName("div")
.addEventListener('input', function() { ... }));
并将此html属性 contenteditable="true"
添加到您的div。
https://stackoverflow.com/questions/45520785
复制相似问题