简体   繁体   中英

Uncaught Type Error: Undefined is not a function JavaScript

In the script section, i get the Uncaught Type Error: Undefined is not a function JavaScript error. What might be wrong? I checked to see if the .js files have been called, and everything is in order.

@model Crux.Models.Question
@{
  ViewBag.Title = "Create";
  Layout = "~/Views/Shared/_Layout.cshtml";
}
<link href="~/Content/jquery.tagit.css" rel="stylesheet" />
<script src="~/Scripts/jquery-2.1.1.min.js"></script>
<script src="~/Scripts/jquery-ui.js"></script>
<script src="~/Scripts/tag-it.js"></script>
<link href="~/Content/jquery-ui.min.css" rel="stylesheet" />

<h2>Create</h2>
@using (Html.BeginForm())
{
  @Html.AntiForgeryToken()
  <div class="form-horizontal">
    <h4>Question</h4>
    <hr />
    @Html.ValidationSummary(true)
    <div class="form-group">
      @Html.LabelFor(model => model.question, new { @class = "control-label col-md-2" })
      <div class="col-md-10">
        @Html.EditorFor(model => model.question)
        @Html.ValidationMessageFor(model => model.question)
      </div>
    </div>
    <div class="form-group">
      <label for="hashtags" class="control-label col-md-2">Tags</label>
      <div class="col-md-10">
        <input id="hashtags" name="hashtags" class="form-control">
      </div>
    </div>
    <div class="form-group">
      <div class="col-md-offset-2 col-md-10">
        <input type="submit" value="Create" class="btn btn-default" />
      </div>
    </div>
  </div>
}
<div>
  @Html.ActionLink("Back to List", "Index")
</div>

<script type="text/javascript">
  $(document).ready(function () {
    $("#hashtags").tagit({
      allowSpaces: false,
      singleField: true,
      singleFieldNode: $('#hashtags'),
      availableTags: ["c++", "java", "php", "javascript", "ruby", "python", "c"]
    });
  }); 
</script>

It gives the error on line: $("#hashtags").tagit({

I was clashing jQuery by loading it three different times. from bundles and the page itself. removed all the links, and finally worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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