简体   繁体   English

将JQuery替换为contenteditable元素事件绑定

[英]Replace JQuery for contenteditable element event binding

I'm using JQuery in my project, and the only line it gets used is the following: 我在项目中使用的是JQuery,它唯一使用的行如下:

$('#div').on('input', function() { ... });

Is there a more lightweight lib/polyfill I can use instead, which allows to register an input event on a contenteditable div? 我可以使用更轻量的lib / polyfill来代替,它允许在contenteditable div上注册输入事件吗?

In pure javascript you can do something likes that : 纯JavaScript中,您可以执行以下操作:

document
   .getElementsByTagName("div")
   .addEventListener('input', function() { ... }));

And add this html attribute contenteditable="true" on your div. 并在div上添加此html属性 contenteditable="true"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM