Error in .js file

0

Include an .js file in an MVC project. my .js file looks like this:

$(document).ready(function() {

    function escondePanel(painel) {
        $("#pnPessoal").css("display", "none");
        $("#pnContato").css("display", "none");
        $("#pnDocumento").css("display", "none");
        $("#pnOutro").css("display", "none");
        $(painel).css("display", "block");
    }

    $("#pessoal").on("click", function () {
        escondePanel("#pnPessoal");
    });

    $("#contato").on("click", function () {
        escondePanel("#pnContato");
    });

    $("#documento").on("click", function () {
        escondePanel("#pnDocumento");
    });

    $("#outro").on("click", function () {
        escondePanel("#pnOutro");
    });

});

I included the .js file in Mmnha view like this:

@Scripts.Render("~/Scripts/code-servidor.js")

But the code is not working and I'm getting the error in the console:

  

ReferenceError: $ is not defined - line 1.1

What's wrong? I've copied the structure of another file that works normally.

    
asked by anonymous 12.08.2017 / 04:03

1 answer

1

jQuery is missing (import)

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    
12.08.2017 / 04:17