简体   繁体   English

未捕获的TypeError:对象.NumCon没有方法'apply'

[英]Uncaught TypeError: Object .NumCon has no method 'apply'

I want run a jquery code that if number value text input was under of 7 , the result is false. 我想运行一个jquery代码,如果数值文本输入低于7 ,则结果为false。 but i get following error: 但我得到以下错误:

 Uncaught TypeError: Object .NumCon has no method 'apply'
     f.event.dispatch
     f.event.add.h.handle.i

What do i do? 我该怎么办?

Demo: http://jsfiddle.net/FZMsP/ 演示: http//jsfiddle.net/FZMsP/

This is my code: 这是我的代码:

<form>
    <input type="password" name="user_pass" class="NumCon" id="7">
</form>

​
function NumCon() {
    var result = true;
    $(this).closest("form").find('.NumCon').each(function () {
        var size = this.value.length;
        var NumVal = $(this).attr('id');
        if (size <= NumVal) {
            $(this).css("background", "#ffc4c4");
            result = false;
        }else{
            $(this).css("background-color", "#ffffec");
        }
    });
}

$('.NumCon').live('keyup', NumCon());​

You're calling your function from inside of the definition line, which is (for some reason) then interpreted as an object. 你是从定义行内部调用你的函数,这是(出于某种原因)然后被解释为一个对象。

$('.NumCon').on('keyup', NumCon);​

Solves your problem. 解决你的问题。

.live has now been depreciated, seems youre now meant to use: $(document).on("click", "a.offsite", function(){ alert("Goodbye!"); }); .live现在已被折旧,现在看来你现在打算使用:$(document).on(“click”,“a.offsite”,function(){alert(“Goodbye!”);});

Jquery .live Jquery .live

​The solution is 解决方案是

$('.NumCon').on('keyup', yourFunction(yourParameters));

source http://api.jquery.com/on/ 来源http://api.jquery.com/on/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的TypeError:对象[object Object]没有方法&#39;apply&#39; - Uncaught TypeError: Object [object Object] has no method 'apply' 未捕获的TypeError:Object# <Object> 没有方法&#39;apply&#39;错误 - Uncaught TypeError: Object #<Object> has no method 'apply' error 未捕获的TypeError:对象(JS函数)没有方法“应用” - Uncaught TypeError: Object (JS Function) has no method 'apply' ScriptSharp:未捕获的TypeError:对象# <HTMLInputElement> 没有方法“应用” - ScriptSharp : Uncaught TypeError: Object #<HTMLInputElement> has no method 'apply' 未捕获的TypeError:对象没有方法“打开” - Uncaught TypeError: Object has no method 'on' 未捕获的typeerror:对象# <object> 没有方法“方法” - Uncaught typeerror: Object #<object> has no method 'method' Backbone.js - 未捕获TypeError:对象[object Object]没有方法&#39;apply&#39; - Backbone.js - Uncaught TypeError: Object [object Object] has no method 'apply' Backbone.js:未捕获的TypeError:对象[object Object]没有方法&#39;apply&#39; - Backbone.js: Uncaught TypeError: Object [object Object] has no method 'apply' Backbone.Model =&gt;未捕获的TypeError:对象[Object object]没有方法&#39;apply&#39; - Backbone.Model => Uncaught TypeError: Object [Object object] has not method 'apply' 未捕获的TypeError:Object [object object]没有方法&#39;on&#39; - Uncaught TypeError:Object[object object] has no method 'on'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM