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");
});
});
精彩评论