Hi guys,
I've just created a new ASP.NET MVC application within Visual Studio 2013. But, I ammediately run into problems. When I try to use jQuery, i get the "JavaScript runtime error: '$' is undefined" error.
I didn't modify anything. The only thing I added was:
<pre lang="HTML">
<script>
alert($("#col-md-4").val());
alert($(".col-md-4").val());
</script>
This is the body part of my layout file
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Application name", "Index", "Home", null, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
@Html.Partial("_LoginPartial")
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
</body>
I've got the bundels in the "BundleConfig.cs" and I've got the jquery file's like "jquery-1.10.2.js" in the scripts folder. Which is all generated when created an ASP.NET MVC project.
Can anyone tell me what's wrong here?
Many thanks in advance!