Oliver Wolf
Oliver Wolf

Reputation: 309

Replace JQuery for contenteditable element event binding

I'm using JQuery in my project, and the only line it gets used is the following:

$('#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?

Upvotes: 0

Views: 82

Answers (1)

Martin Choraine
Martin Choraine

Reputation: 2431

In pure javascript you can do something likes that :

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

And add this html attribute contenteditable="true" on your div.

Upvotes: 1

Related Questions