Sparky
Sparky

Reputation: 4879

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() 
{$("#btn1").click(function()
{
alert("55");
}}
));
</script>

Please tell me what is wrong with the script.

Upvotes: 0

Views: 330

Answers (2)

Fr&#233;d&#233;ric Hamidi
Fr&#233;d&#233;ric Hamidi

Reputation: 263157

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

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

Upvotes: 6

rahul
rahul

Reputation: 187110

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");
    });
});

Upvotes: 1

Related Questions