开发者

jQuery script not working

I was learning jQuery basics. Below is a simple alert box, but it won't work. Please help me. I have a with id="btn1"

<script type="text/javascript" >
$(document).ready(function() 
{$开发者_StackOverflow社区("#btn1").click(function()
{
alert("55");
}}
));
</script>

Please tell me what is wrong with the script.


You have mismatched curly braces and parenthesis. You should write:

<script type="text/javascript">
    $(document).ready(function() {
        $("#btn1").click(function() {
            alert("55");
        });
    });
</script>


Include jQuery.js file and refer that file in your code.

<script src="path to your jquery file" type="text/javascript"></script>   


$(function(){
    $("#btn1").click(function(){
        alert("55");
    });
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜