How to determine when text input changes with ie8

I want to determine when text input changes. I tried these that worked in firefox but not in 8.

$('#taskSearch').bind('input', function() { alert($(this).val()); }); $('#taskSearch').live('input', function() { alert($(this).val()); }); $('#taskSearch').change(function() { alert($(this).val()); }); 
+6
javascript jquery
source share
7 answers

You can use onpropertychange for IE6 +:

 $("#taskSearch").on("propertychange", function(){ alert($(this).val()); }); 
+11
source share

The last (and only the last) is correct, but you are missing the closing parenthesis:

 $('#taskSearch').change(function() { alert($(this).val()); }); 

.live() deprecated (and the syntax is incorrect), and the syntax for .bind() also incorrect; the event name is 'change' , not 'input' . See the documentation for .change() .

+2
source share

The following solution works for me in IE8 and modern browsers for both changes using the keys, scroll, or arrow buttons in the input field type = "num":

 $('#element').on('keyup change', function() { // do something }); 
+2
source share

https://github.com/spicyj/jquery-splendid-textchange is a plugin for fixing quirks of emulating "input" in IE8 and IE9.

The author described how he reached this decision on his blog ( http://benalpert.com/2013/06/18/a-near-perfect-oninput-shim-for-ie-8-and-9.html ), which really complicated, read if you want to know the details.

+1
source share
 $('#taskSearch').change(function() { alert($(this).val()); // not the extra brace I've added }); 

It should just work. .live() stop using .live() .

0
source share

This will detect when a key is pressed in IE8

$ ("# input"). on ('keyup', function (event) {alert ('keypress');});

0
source share

To start immediately when the input value changes:

 $('#example')on('keyup input', function(e){ alert(e.type); // Displays 'keyup' in IE8, 'input' in browsers }); 

(This is an answer from Mark)

0
source share

All Articles