Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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 创建新todos代码生成错误_Javascript_Jquery_Html_Css_Error Handling - Fatal编程技术网

Javascript 创建新todos代码生成错误

Javascript 创建新todos代码生成错误,javascript,jquery,html,css,error-handling,Javascript,Jquery,Html,Css,Error Handling,我正在使用jQuery 2.4.1 min版本构建一个简单的todo列表项目,但创建新的todo时出现以下错误: todos.js:12 Uncaught TypeError: event.stopPropogation is not a function at HTMLSpanElement.<anonymous> (todos.js:12) at HTMLUListElement.dispatch (jquery-2.1.4.min.js:3) at HTMLUListEleme

我正在使用jQuery 2.4.1 min版本构建一个简单的todo列表项目,但创建新的todo时出现以下错误:

todos.js:12 Uncaught TypeError: event.stopPropogation is not a function
at HTMLSpanElement.<anonymous> (todos.js:12)
at HTMLUListElement.dispatch (jquery-2.1.4.min.js:3)
at HTMLUListElement.r.handle (jquery-2.1.4.min.js:3)
(anonymous) @ todos.js:12
dispatch @ jquery-2.1.4.min.js:3
r.handle @ jquery-2.1.4.min.js:3
todos.js:12未捕获类型错误:event.stopPropogation不是函数
在HTMLSPANENT。(todos.js:12)
在HtmlListElement.dispatch(jquery-2.1.4.min.js:3)
在htmlListElement.r.handle(jquery-2.1.4.min.js:3)
(匿名)@todos.js:12
dispatch@jquery-2.1.4.min.js:3
r、 handle@jquery-2.1.4.min.js:3
Js文件:

$("ul").on("click", "li", function(){
    $(this).toggleClass("completed");

});

$("ul").on("click","span",function(event){

    $(this).parent().fadeOut(500,function(){
        $(this).remove();
    });

event.stopPropogation();
});

$("input[type='text']").keypress(function(event){

    if(event.which === 13)
    {
        var todosText=$(this).val();
        $(this).val("");
        $("ul").append("<li><span>X<span> " + todosText + "<li>");

    }

});

$(“ul”)。在(“单击”,“li”,函数()上){
$(此).toggleClass(“已完成”);
});
$(“ul”)。在(“单击”,“跨距”,功能(事件){
$(this.parent().fadeOut(500,function()){
$(this.remove();
});
event.stopPropogation();
});
$(“输入[type='text']”)。按键(函数(事件){
if(event.which==13)
{
var todosText=$(this.val();
$(此).val(“”);
$(“ul”)。追加(“
  • X”+todosText+”
  • ”; } });
  • 您在
    事件.stopPropogation()中有拼写错误。
    。您必须写入
    事件.停止播放()
    。希望这能解决您的问题。

    您在
    事件.stopPropogation()中有拼写错误。
    。您必须写入
    事件.停止播放()
    。希望这能解决您的问题。

    是的,它确实消除了错误,但新TODO的创建仍然无法正常运行。在附加html时,关闭标记中也缺少“/”。与
  • 的结束标记一样,它应该是
  • 。同样的道理,这是正确的答案。如果您仍然存在问题,您应该提出一个新问题。是的,它确实删除了错误,但新TODO的创建仍然无法正常运行。在附加html时,关闭标记中也缺少“/”。与
  • 的结束标记一样,它应该是
  • 。同样的道理,这是正确的答案。如果你仍然有问题,你应该提出一个新问题。