-1

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.

2 Answers 2

6

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

<script type="text/javascript">
    $(document).ready(function() {
        $("#btn1").click(function() {
            alert("55");
        });
    });
</script>
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

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.