Ben Hathaway
Ben Hathaway

Reputation: 356

JQuery isn't working in my html document

Hi I have some Jquery in my html doc, however it doesn't seem to work. I know the code is correct as it works perfectly fine in 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>

Upvotes: 0

Views: 77

Answers (1)

Adil Shaikh
Adil Shaikh

Reputation: 44740

If you are running that locally you need to put http: in your jquery url -

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

Upvotes: 3

Related Questions