Reputation: 4879
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
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
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