如何使用ie8检测文本输入何时更改 [英] How to detect when a text input changes with ie8

查看:67
本文介绍了如何使用ie8检测文本输入何时更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测文本输入何时更改. 我尝试了这些,但它们在Firefox中有效,但在ie 8中无效.

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());
});

推荐答案

您可以将onpropertychange用于IE6 +:

You can use onpropertychange for IE6+:

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

这篇关于如何使用ie8检测文本输入何时更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆