Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery动态事件处理程序错误_Javascript_Jquery_Event Handling_Extension Methods_Jquery Events - Fatal编程技术网

Javascript jQuery动态事件处理程序错误

Javascript jQuery动态事件处理程序错误,javascript,jquery,event-handling,extension-methods,jquery-events,Javascript,Jquery,Event Handling,Extension Methods,Jquery Events,我为动态创建的DOM元素创建了一个事件处理程序,但收到一个错误。我犯了一个错误,但这里没有发生错误,只是在我的应用程序中 我已经包括了两个事件处理程序,change和click。更改是我唯一关心的:我只包括了单击以确保动态DOM元素上的事件处理程序能够工作 如果你不想看演示,下面是我使用的一个单词和字符计数器插件的基本代码,它使用.Counter方法,你可以在http://qwertypants.github.io/jQuery-Word-and-Character-Counter-Plugin

我为动态创建的DOM元素创建了一个事件处理程序,但收到一个错误。我犯了一个错误,但这里没有发生错误,只是在我的应用程序中

我已经包括了两个事件处理程序,change和click。更改是我唯一关心的:我只包括了单击以确保动态DOM元素上的事件处理程序能够工作

如果你不想看演示,下面是我使用的一个单词和字符计数器插件的基本代码,它使用.Counter方法,你可以在http://qwertypants.github.io/jQuery-Word-and-Character-Counter-Plugin/ :

下面是我在Chrome中的一个很长的重复错误

这是踢球的人。。。 .onclick事件在我的应用程序中运行良好,而从扩展名$.text手动触发的.onchange则不行,即使它在JSFIDLE中运行

有人知道为什么会发生这种错误吗

感谢阅读。

jsiddle演示

工作样本

注意:我使用的插件不是缩小版,chrome控制台中也没有错误

您是否尝试将更改重命名为自定义名称?对我来说,在内容元素上使用表单控件事件名称没有多大意义您已经使用了完整版本的url
<!doctype html>
<html>
<head>
    <script>//plugin</script>
    <script>
        $(document).ready(function() {
            $("#myTextArea").counter();
            //Below, my selector is called myTextArea_count because the plugin creates a <span> with an id
            //equal to the id of the element it is counting for, with "_count" appended.
            $(document).on("change", "#myTextArea_count", function() {
                $("<p>Count changed</p>").appendTo("#myTextArea_counter");
            });
            $(document).on("click", "#myTextArea_count", function () {
                var $this = $(this);
                if ($this.css("color") == "rgb(0, 0, 0)") {
                    $this.css("color", "orange");
                }
                else {
                    $this.css("color", "black");
                }
            });
        });
    </script>
</head>
<body>
    <textarea id="myTextArea" rows="4" cols="50"></textarea>
</body>
</html>
http://jsfiddle.net/nadeemmnn2007/akkvbu0u/4/
<!doctype html>
<html>
<head>


</head>
<body>
    <textarea id="myTextArea" rows="4" cols="50"></textarea>


    <script type="text/JavaScript" src="jquery.js"></script>
    <script src="word-and-character-counter.js"></script>
    <script>
        $(document).ready(function() {

            $("#myTextArea").counter({ count: 'up',
    goal: 10});
            //Below, my selector is called myTextArea_count because the plugin creates a <span> with an id
            //equal to the id of the element it is counting for, with "_count" appended.
            $(document).on("change", "#myTextArea_count", function() {
                $("<p>Count changed</p>").appendTo("#myTextArea_counter");
            });
            $(document).on("click", "#myTextArea_count", function () {
                var $this = $(this);
                if ($this.css("color") == "rgb(0, 0, 0)") {
                    $this.css("color", "orange");
                }
                else {
                    $this.css("color", "black");
                }
            });
        });
    </script>



</body>
</html>