简体   繁体   English

jQuery在我的html文档中不起作用

[英]JQuery isn't working in my html document

Hi I have some Jquery in my html doc, however it doesn't seem to work. 嗨,我的html文档中有一些Jquery,但是它似乎不起作用。 I know the code is correct as it works perfectly fine in JSfiddle. 我知道代码是正确的,因为它在JSfiddle中工作得很好。 Can anyone see where I am going wrong? 谁能看到我要去哪里错了?

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <meta charset="utf8">

    <script type="text/javascript">

$(function () {
    var addDiv = $('#addinput');
    var i = $('#addinput p').size() + 1;

    $('#addNew').on('click', function () {
        $('<p><input type="text" class="p_new" size="40" name="utensil_descrip' + i + '" value="" placeholder="Utensil Description" /><a href="#" class="remNew">Remove</a> </p>').appendTo(addDiv);
        i++;
        return false;
    });
    $(document).on('click','.remNew', function () {
        if (i > 2) {
            $(this).parents('p').remove();
            i--;
        }
        return false;
    });
});

    </script>

  </head>

If you are running that locally you need to put http: in your jquery url - 如果您在本地运行该代码,则需要在您的jquery网址中输入http:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
              ^-------------------

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM