我在 IE9 中收到此错误,指向下面代码片段中的行 return self.subQuantity.val();
。可能是什么原因造成的?
我应该添加这个在 FF 中完美运行。
部分功能:
$(document).ready(function() {
plan = (function() {
var plan = {
subQuantity: $('.downgrade .count'),
...
init: function(productCatalog) {
this.prod = productCatalog;
this.reset();
self = this;
this.fetchButton.bind('click', function(e) {
self.fetchScenarii();
return false;
}).filter(function() {
return self.subQuantity.val();
})
}
HTML
<div class="downgrade">
...
<input type="count" name="count" />
...
</div>
最佳答案
self = this;
是错误。您正在写信给global self
variable (引用window
)这里 - 在 IE 中是不可写的。添加var
declaration
var self = this;
它会起作用。
关于javascript - jQuery IE9 : Unable to get value of the property 'val' : object is null or undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8790348/