How to use jquery in ASP.​NET Core

后端 未结 3 545
一个人的身影
一个人的身影 2020-12-29 23:19

I created a ASP.NET core template and wrote a jquery script. When I look at the page I see that jquery is loaded into the page, but the script doesn’t run. I looked at the A

3条回答
  •  一个人的身影
    2020-12-29 23:45

    FOR CLARIFICATION


    If you are referencing jQuery in your _Layout page.. double check to ensure that that reference is at the TOP of your _Layout page because if it is at the bottom, then every other page you have that use the _Layout and has jQuery, it will give you errors such as:

    $ is undefined

    because you are trying to use jQuery before it is ever defined!

    Also, if your are referencing jQuery in your _Layout page then you do not need to reference it again in your pages that use your _Layout style


    Make sure that you are loading the reference to jQuery before you start using .

    Your cshtml should work if you put the reference above your script as so:

     // or whatever version you are using
    
    // you do not need to use this reference if you are already referencing jQuery in your Layout page
    
    
    

提交回复
热议问题