我有以下代码并且我一直收到此错误:
错误似乎就在这一行:
self.attr(rule.attr);
这是代码
/* @type {Object} */
var settings = $.extend({
value: null,
rules: [{
'operator': null,
'value': null,
'attr': {},
'callback': null
}]
}, options || {});
var locale = $('html').attr('lang');
return this.each(function () {
var self = $(this);
var elementValue = (settings.value) ? settings.value : self.text();
elementValue = elementValue.replace(/[^0-9,\.-]/g, "");
if (locale.indexOf("de") > -1) {
elementValue = elementValue.replace('.', '').replace(',', '.');
} else {
elementValue = elementValue.replace(',', '');
}
elementValue = parseFloat(elementValue);
if (!isNaN(elementValue)) {
$.each(settings.rules, function (key, rule) {
if (typeof rule.value === 'number') {
var operator = '>';
if (typeof rule.operator === 'string') {
operator = rule.operator;
}
if (eval(elementValue + ' ' + operator + ' ' + rule.value)) {
if (rule.callback) {
rule.callback(self);
} else {
self.attr(rule.attr);
}
}
}
});
}
});
关于我做错的任何想法?