0

I've looked at a fair few suggestions and similar questions to this but the solutions haven't worked thus far. Originally I tried to use a button to activate a Web API I was using however the button itself wouldn't trigger. Then I realised it wasn't the API that wasn't working, it's the button. I've tried to rewrite the button to be much simpler just for the sake of seeing if it works and still no result. The code looks like this:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script>
        $(document).ready(function () {
            $("#TestButton").click(function () {
                alert("Hello World")
            });
        }                    
    </script>

    <button id="TestButton"> Click here for test </button>

When I click the button the alert doesn't activate and I don't know why. It may be worth mentioning that I've written this on an .aspx page but I've not used any asp.net syntax.

1
  • Typo. The browser's console is telling you the problem. You never closed the .ready() function. Commented Sep 30, 2020 at 14:36

1 Answer 1

2

You missed closing parenthesis

$(document).ready(function () {
            $("#TestButton").click(function () {
                alert("Hello World");
            });
 });
Sign up to request clarification or add additional context in comments.

Comments

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.