开发者

jQuery: Issue Using Bind & Click Methods

开发者 https://www.devze.com 2023-03-06 00:57 出处:网络
Any idea why this click event isn\'t working?(I\'m sure the answer is obvious - I\'m just not seeing it).

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 catch开发者_开发技巧ing this typo. I need to remember to have firebug open next time. Thanks for suggesting jsfiddle.net. Looks like a cool site.


$(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.

0

精彩评论

暂无评论...
验证码 换一张
取 消