Uncaught ReferenceError: $ is not defined error in jQuery

前端 未结 4 2140
无人共我
无人共我 2020-11-29 10:49

I have this code in jQuery: (the file name is javascript.js ...I was using JavaScript before...)

$(document).ready(function() {
 $(\"#readFile\"         


        
4条回答
  •  余生分开走
    2020-11-29 11:10

    The MVC 5 stock install puts javascript references in the _Layout.cshtml file that is shared in all pages. So the javascript files were below the main content and document.ready function where all my $'s were.

    BOTTOM PART OF _Layout.cshtml:

        
    @RenderBody()

    © @DateTime.Now.Year - My ASP.NET Application

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

    I moved them above the @RenderBody() and all was fine.

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

    © @DateTime.Now.Year - My ASP.NET Application

提交回复
热议问题