问题
$(":input").change(function() {alert("hello");}
Basic idea is when input changes, do the function. But it wouldn't work with IE8, when I changed some words in the input text field, the function was not triggered. This does not happen with other versions of IE(9+) or other browsers.
回答1:
Maybe its an issue with the event itself. maybe try:
var ie8 = /msie 8/gi.test(window.navigator.userAgent);
$("input").bind(ie8 ? 'propertychange' : 'change', function() {
alert("hello");
}
Edit Note: Newer jQuery versions take of this themselves!
And for lower IE8, if needed:
var lowIE = /msie (6|7|8)/gi.test(window.navigator.userAgent);
$("input").bind(lowIE ? 'propertychange' : 'change', function() {
alert("hello");
}
来源:https://stackoverflow.com/questions/17359952/jquery-why-this-does-not-work-input-changefunction