Both in IE and EVEN:

This WILL work:

$("#bar").click(function() {
        var chk = $("#foo")[0];
        var val = chk.checked;
        alert(val);
        chk.checked = !val;
});

Apparently, when reading, checked is an attribute, but when writing, it isn't?
I bet someone already knows the answer, for now, the workaround works.


On 9/6/06, Dylan Verheul <[EMAIL PROTECTED]> wrote:
> You're right, but it should work.
>
> Anyone else?
>
> js:
> $("#bar").click(function() {
>         var checked = $("#foo").attr("checked");
>         $("#foo").attr("checked", !checked);
> });
>
> html:
> <input id="foo" type="checkbox" value="OK" /> <input id="bar"
> type="button" value="Test" />
>
> result:
> first click of the button sets the checkbox to checked, next clicks it
> remains checked.
>
> On 9/6/06, David Gironella <[EMAIL PROTECTED]> wrote:
> > This always return to me null, if checkbox is checked or not.
> >
> > Giro.
> >
> > -----Mensaje original-----
> > De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] En nombre
> > de Dylan Verheul
> > Enviado el: miƩrcoles, 06 de septiembre de 2006 14:42
> > Para: jQuery Discussion.
> > Asunto: Re: [jQuery] Checked input box
> >
> > $('#mycheck').attr("checked")
> >
> > On 9/6/06, David Gironella <[EMAIL PROTECTED]> wrote:
> > >
> > > I can check a chekckbox input
> > >
> > > Something that it
> > >
> > > <input type="checkbox" id="mycheck">
> > >
> > > $('#mycheck').checked(); and return true or false
> >
> > _______________________________________________
> > jQuery mailing list
> > discuss@jquery.com
> > http://jquery.com/discuss/
> >
> >
> > _______________________________________________
> > jQuery mailing list
> > discuss@jquery.com
> > http://jquery.com/discuss/
> >
>

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to