Error in file . js

Asked

Viewed 43 times

0

Included a . 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");
    });

});

Include the file . js in Mmnha view like this:

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

However the code is not working and I’m getting the error on the console:

Referenceerror: $ is not defined - line 1.1

What’s wrong? Because I copied the structure of another file of mine that works normally.

1 answer

1


Missing include (import) the jQuery

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.