How to insert jQuery code? Uncaught ReferenceError: $ is not defined in view razor code

前端 未结 5 1942
执念已碎
执念已碎 2020-12-31 06:54

I have the following Asp.Net MVC 4 razor code at the end of the file.

....
@section Scripts {
    @Scripts.Render(\"~/bundles/jqueryval\")
}



        
5条回答
  •  不知归路
    2020-12-31 07:22

    Move the following lines of code to the top of your _Layout.cshtml view inside of the body tag. Then the jQuery scripts will load first.

    
        @Scripts.Render("~/bundles/jquery")
        @Scripts.Render("~/bundles/bootstrap")
        @RenderSection("scripts", required: false)
    

提交回复
热议问题