jQuery为什么这不工作$(":input")。change(function(){}); [英] jQuery why this does not work $(":input").change(function(){});
本文介绍了jQuery为什么这不工作$(":input")。change(function(){});的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$(":input").change(function() {alert("hello");}
基本思想是当输入变化时,执行函数,但它不会与IE8工作,当我改变输入文本字段中的一些单词,函数没有被触发。这不会发生在其他版本的IE(9+)或其他浏览器。
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.
推荐答案
也许它的事件本身的问题可能尝试:
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");
}
编辑
注意:较新的jQuery版本会自动使用!
对于较低的IE8,如果需要:
And for lower IE8, if needed:
var lowIE = / msie(6 | 7 | 8)/gi.test .navigator.userAgent);
var lowIE = /msie (6|7|8)/gi.test(window.navigator.userAgent);
$("input").bind(lowIE ? 'propertychange' : 'change', function() {
alert("hello");
}
这篇关于jQuery为什么这不工作$(":input")。change(function(){});的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文