js:jquery&&prototype// 类声明方法 怎么被该类中声明的另一个方法调用

henji0715 henji0715 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
Function.prototype.addMethod=function(name,fn){
this.prototype[name]=fn;
}
function Methods(){
this.test=function(){alert('test');};

//Methods.span=document.createElement('span');//here can not destroy var span
Methods.addMethod('condition',function(obj,str,min,max){
alert('method1');
if(obj.val().length<min||obj.val().length>max){
var span = document.createElement('span');// destroy var span
//JQ=$ of jquery
if(JQ('#error_msg').html()!=undefined)
JQ('#error_msg').remove();
span.innerHTML=str;
span.setAttribute('style','color:red');
span.setAttribute('id','error_msg');
obj[0].parentNode.insertBefore(span,obj[0]);
span =null;
}
})
//.addMethod('checkUserName',function(){
// condition(JQ('#username'),'帐号输入超出范围',6,12);
//}).addMethod('checkPwd',function(){
// condition(JQ('#pwd'),'密码输入超出范围!',6,20);
//}).addMethod('checkPhone',function(){
// condition(JQ('phone'),'手机号码输入不正确!',11,11);
//});
};
JQ(function(){
alert('sss');
var m = new Methods()
m.test();
m.condition(JQ('#username'),'帐号输入超出范围',6,12);
// JQ('#username').blur(m.checkUserName());
// JQ('#pwd').blur(m.checkPwd());
// JQ('#phone').blur(m.checkPhone());
});
注销掉的方法去调用condition 方法 报未定义或者null引用的属性Methods,这个怎么调用啊,求大神指点!
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
henji0715
JavaScript 87,983 成员 224,681 内容