How are you calling the check? You haven't provided the code for the
actual selection event.
Your code should look along the lines of:

$("#chk01").click(function() {
     if ( $(this).is(':checked') ) {
          // do something
     }
     else {
          // do something else
     }
});

Also, make sure you only have one ID called "chk01" on your page.

On Apr 7, 8:15 pm, Eric <morningsunsh...@gmail.com> wrote:
> Hi,
>
> I am having a simple issue but can't get it work. I've searched other
> similar posts but still no good luck.
>
> I've got a checkbox on my form not checked by default and it's up to
> the user to select it.
>
> <input id="chk01" name="chk01" type="checkbox">
>
> I then want to detect if user has selected it or not in jQuery
> (triggered by some event)
>
> I've tried to use $("#chk01").attr("checked") which always gives me
> "undefined" value no matter if it is checked or not.
>
> Also tried $("#chk01").is(':checked') which always gives me 'false' no
> matter if it is checked or not.
>
> I did this in FFox with FireBug. I also noticed that as user check/
> uncheck the box, the underlying html is not updated (always remains
> initial value), which is probably why the attr function is unable to
> pick up the value.
>
> Can anyone help?
>
> Thanks,
>
> Eric

Reply via email to