The alert box does not appear when you click the check box

advertisements

I can't see any error in my code. However, the Alertbox doesn't display when checkbox is ticking.

Is there anyone can help me? Thanks in advance.

 <script type="text/javascript" language="javascript" src="jquery/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" language="javascript">
    $(function(){

              if($("#checkkBoxId").attr("checked"))
                        {
                            alert("Checked");
                        }
                        else
                        {
                            alert("Unchecked");
                        }

    });

    </script>
    </head>

    <body>

        <p><input id="checkkBoxId" type="checkbox">Enable</p>
    </body>


you need to bind the click event on the checkbox like

$("#checkkBoxId").click(function() {
    if($(this).attr("checked")) {
        alert("Checked");
    }
    else {
        alert("Unchecked");
    }
}):