Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery上的更改和输入函数多次运行_Javascript_Jquery_Function_Jquery Selectors - Fatal编程技术网

Javascript jquery上的更改和输入函数多次运行

Javascript jquery上的更改和输入函数多次运行,javascript,jquery,function,jquery-selectors,Javascript,Jquery,Function,Jquery Selectors,在我的代码中有140个选择器和2个事件(更改、输入) 当我减少选择器的数量时,返回时间也会减少,但我需要所有选择器。 我用了这些方法 $("#selector1, #selector2, #selector3, ...... #selector139, #selector140").off('change input').on('change input',function(e){ console.log('test')//it returns 28 times //My j

在我的代码中有140个选择器和2个事件(更改、输入)

当我减少选择器的数量时,返回时间也会减少,但我需要所有选择器。
我用了这些方法

$("#selector1, #selector2, #selector3, ...... #selector139, #selector140").off('change input').on('change input',function(e){
    console.log('test')//it returns 28 times  
    //My jquery code
}
但输入事件不起作用

$("#selector1, #selector2, #selector3, ...... #selector139, #selector140").on('change input', function(e){ 
 if(e.handled !== true) 
{
    //Code 
    e.handled = true;
}

});
但这种方法也不起作用 我使用了
one()
函数,但它不能正常工作。

有没有办法解决这个问题?

谢谢

最好改用
class
。 只需向输入中添加一个类,如下所示:

<input class="someclass" type="text" />

为什么不改用类呢?你不应该有那么多的ID,这正是我要建议的@CertainPerformanceAll元素是
输入
?如果不是,当然输入事件不起作用。所有元素都是100%的输入
<input class="someclass" type="text" />
$('.someclass').on('input change',function() {
    //do what you want
});