dimanche 26 juillet 2015

How to check if checkbox is checked in asp.net view using Jquery?

I am trying to find out whenever a checkbox on my page is checked and unchecked. I console log to find out the status, but I am always getting an "unchecked" result. What am I doing wrong?

...
<input type="checkbox" id="checkbox_addAuthor" name="checkbox_addAuthor" />

</div>
</form>

@section Scripts
{
<script type="text/javascript">
    var checkbox = $('#checkbox_addAuthor');
    var authorList = $('#AuthorList');

    checkbox.on('click',function(){

        if(checkbox.Checked == true)
        {
           console.log("I am checked")
        }
        else {
            console.log("I am not checked");
        }

    })

</script>
}

When I run this, the console always prints out "I am not checked". Cant figure out why.




Aucun commentaire:

Enregistrer un commentaire