asp.net mvc4 jquery not working

前端 未结 3 1426
无人共我
无人共我 2021-02-18 20:55

I\'m trying to run a jquery code which was put in my _Layout.cshtml as below:

...............


        
3条回答
  •  盖世英雄少女心
    2021-02-18 21:24

    In order for jQuery to work, your script should come after

    In the _Layout.cshtml, just before the tag you can find something like this

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

    First you have the jQuery library. Then you have any scripts. That's what this means. So in your views do something like this.

    @section scripts{
     //your script
    }
    

    This will make sure that all scripts comes under jQuery reference.

提交回复
热议问题