Could not execute onclick function using jquery : The onclick event is unable to execute using Jquery. I am explaining my code below.

    <input type="checkbox" id="carsval" value="1" name="carsval" <?php if($isCar==1){echo 'checked="checked"';} ?> >
    <script type="text/javascript">
                  $(document).ready(function(){
                    if ($('.checkboxdiv input:checkbox').attr('checked')) {
                      $('.checkboxdiv input:checkbox').removeAttr('checked');
                    }
                    $('#carsval').click(function(){
                        alert('did it');
                    })
                  })
                </script>

Here inside the click function the alert is not executing after click on check box.