Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$(document).on("input",".SomeClass") works on Chrome but not IE

I have a span with contenteditable tag and I have a function used to detect input into it..

//TextArea
<span class="SomeClass" contenteditable></span>

//Function
$(document).on("input", ".SomeClass", function () {
    console.log("input entered");
});

This works for me on Chrome but not on the IE 11 or below. I can't seem to find any mention of it online and was wondering if anyone could give me information on how to get this working or a better approach.

Thanks

like image 808
RichardMc Avatar asked Feb 13 '23 20:02

RichardMc


1 Answers

This is a reported bug (#794285) in IE10 and IE11: contenteditable elements do not fire the input event.

A workaround be to handle different event types alongside input, such as keypress, paste and change:

$(document).on("input keypress paste change", ".SomeClass", function () {
    console.log("input entered");
});

JSFiddle demo.

like image 80
James Donnelly Avatar answered Feb 15 '23 11:02

James Donnelly