【发布时间】:2018-09-15 14:04:41
【问题描述】:
我写了一个非常基本的插件,它在模糊事件上被调用,我把它和我写的另一个文件放在一个文件中,效果很好。 当我离开输入字段时,我不断收到一条错误消息,说它未定义,我不确定它为什么一直这样说。
错误:
未捕获的 ReferenceError: Validation_Required 未定义
我的插件是
(function ($) {
// This one works fine, but is called on a button click
$.fn.Validation = function (options)...
// This is the plugin that throws the ReferenceError
$.fn.Validation_Required = function (e) {
let me = $('#' + e.target.id);
if (me[0].value.length > 0) {
me.css('border', '2px solid green');
}
else {
me.css('border', '2px solid red');
}
return;
}
}(jQuery));
函数的调用是
$('.required').blur((e) => {
Validation_Required(e);
});
为什么会抛出错误?
【问题讨论】:
标签: jquery jquery-plugins