0

What i did so far:

Step1: installed "jQuery.UI.Combined" via NuGet
Step2: In my Razorpage I include this code:

<script src="~/lib/jquery/dist/jquery.js" type="text/javascript">
    $(document).ready(function () {
        $("#test").click(function () {
            $("#NavBar_OptionPanel").toggle();
        });
    });
</script>

Step3: This is my Button:

<a id="test">Settings</a>

Step4: This is the Panel i want to toggle on/off:

<div id="NavBar_OptionPanel">
    <label>Options</label>
</div>

What i expected: When clicking on an element with id="test", all elements with id="NavBar_OptionPanel" should toggle on/off

But nothing is happening. So i guess there could be two problems:

  1. The installation of jQuery is wrong/a step missing
  2. The usage of jQuery is wrong

Can you help me?

3
  • 3
    Have you looked at the console for errors? Commented Mar 12, 2018 at 14:12
  • 1
    Step1: installed "jQuery.UI.Combined" via NuGet That's a problem right there. jQuery != jQuery.UI. There's a package called jQuery - install that instead. Commented Mar 12, 2018 at 14:15
  • no errors as far as i can see (i looked into the output window & show output = ASP.net core webserver) Commented Mar 12, 2018 at 14:18

1 Answer 1

4

You have your code inside your script tag including jquery, change it to this:

<script src="~/lib/jquery/dist/jquery.js" type="text/javascript"></script>
<script>
    $(document).ready(function () {
        $("#test").click(function () {
            $("#NavBar_OptionPanel").toggle();
        });
    });
</script>
Sign up to request clarification or add additional context in comments.

1 Comment

that was the problem + installing the wrong package like @Archer said. Thank you for your help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.