开发者

jQuery: Issue Using Bind & Click Methods

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜