热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

jQuerydocument.ready停止代码-jQuerydocument.readystopsthecode

TheproblemIhaverightnowisthatwhenIputthedocument.readycodewrappingmyscriptitstopps

The problem I have right now is that when I put the document.ready code wrapping my script it stopps working. I know I can simply not use it, because I only call the script in the end of my HTML, but I want to know why it is breaking my code. PS: I have already added jQuery Code:

我现在遇到的问题是,当我把document.ready代码包装到我的脚本时,它会停止工作。我知道我不能使用它,因为我只在HTML的末尾调用脚本,但我想知道为什么它会破坏我的代码。 PS:我已经添加了jQuery代码:

    $(document).ready(function () {
        $('.clicker').click(function() {
            if($(this).hasClass('clicker'))
            {
                var row_index = $(this).parents('tr').index();
                $(this).text('Cancelar');
                $(this).attr('class', 'cancelar');
                var index = row_index - 2;
                $(".save:eq("+index+")").css('display', 'inline');
            }
            else 
            {
                $(this).text('Editar');
                $(this).attr('class', 'clicker');
                $('.save').css('display', 'none');
            }
        });
    });
//In the end of the html file:

1 个解决方案

#1


0  

JQuery should be included at the top of the page.

JQuery应该包含在页面顶部。

$ is not defined - You are trying to run Jquery but is is not defined which is breaking your page - your script failing there when you trying to run your document.ready.

$未定义 - 您正在尝试运行Jquery但未定义哪个会破坏您的页面 - 当您尝试运行document.ready时,脚本会失败。


推荐阅读
author-avatar
庾承泓_689
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有