开发者

jQuery script not working

开发者 https://www.devze.com 2023-02-04 15:19 出处:网络
I was learning jQuery basics. Below is a simple alert box, but it won\'t work. Please help me. I have awith id=\"btn1\"

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

精彩评论

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

关注公众号