文本框类的jQuery的Change事件在chrome中不起作用 [英] JQuery on Change event for textbox class not working in chrome
本文介绍了文本框类的jQuery的Change事件在chrome中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一类文本框,并尝试将onChange事件附加到该类上.下面的代码有效,我从firefox中的calData获取了输出,但在Chrome上不起作用
I have a class of textboxes and trying to attach onChange event to the class. Code below works and i get the output from calData in firefox but does not work on Chrome
enter code here
<ul id="week_list">
<li id="34">
Week 1 - <input class="test_class" type="number" id="week_34" name="week[]">
</li>
<li id="35">
Week 2 - <input class="test_class" type="number" id="week_35" name="week[]">
</li>
</ul>
//Javascript
var Test =
{
init: function(config) {
this.bindEvents();
},
bindEvents: function() {
this.config.clTest.on('change',this.calData);
},
calData: function(){
console.log("calculating");
},
};
Test.init({
clTest: $('.test_class'),
});
推荐答案
您需要将js更改为类似
you need to change your js to be something like this
var Test =
{
config:null,
init: function(c) {
config = c;
console.log(config);
this.bindEvents();
},
bindEvents: function() {
config.clTest.on('change',this.calData);
},
calData: function(){
console.log("calculating");
}
};
Test.init({
clTest: $('.test_class'),
});
忘记包含演示
这篇关于文本框类的jQuery的Change事件在chrome中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文