I want to detect when a text input changes. I tried these, which worked in firefox but not in ie 8.
$('#taskSearch').bind('input', function() {
alert($(this).val());
});
$('#taskSearch').live('input', function() {
alert($(this).val());
});
$('#taskSearch').change(function() {
alert($(this).val());
});
You can use onpropertychange
for IE6+:
$("#taskSearch").on("propertychange", function(){
alert($(this).val());
});
The following solution works for me in IE8 and modern browsers for both changes by keys, scroll or the arrow buttons within the a type="num" input field:
$('#element').on('keyup change', function() {
// do something
});
The last one (and only the last one) is correct, but you were missing a closing parenthesis:
$('#taskSearch').change(function() {
alert($(this).val());
});
.live()
is deprecated (and the syntax is incorrect), and the syntax for .bind()
is also incorrect; the name of the event is 'change'
, not 'input'
. See the documentation for .change()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With