1

Any idea why this click event isn't working? (I'm sure the answer is obvious - I'm just not seeing it).

<html>
    <head>
        <title></title>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
            $(document).ready(function() {
                $('h1').bind('click', function(){
                    alert('clicked');
                });
            )};
        </script>
    </head>
    <body>
        <h1>This is a test.</h1>
    </body>
</html>

EDIT: @Stefan: thanks for catching this typo. I need to remember to have firebug open next time. Thanks for suggesting jsfiddle.net. Looks like a cool site.

1 Answer 1

6
$(document).ready(function() {
                $('h1').bind('click', function(){
                    alert('clicked');
                });
            });//note this line

Looks like a typo. Open up firebug, and you should see a JS error.

Here's a working example.

Sign up to request clarification or add additional context in comments.

2 Comments

Almost any IDE would have caught this error. I use Intelli-J Ultimate, and I recommend it highly for JS development with server stuff (it catches a few things Eclipse and Netbeans do not).
I can never tell when those brackets are properly closed without staring for a few minutes—they make me dizzy...

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.