That's right, you want to change the 'checked' attribute, there is an
even simpler way:

        $(':radio').dblclick(function(){
                this.checked = false;
        });

And speaking of attributes, the XHTML standard is checked="checked",
not "true".

        $(':radio').dblclick(function(){
                $(this).attr('checked',''); // empty
                // $(this).attr('checked','checked')
        });

On Jan 8, 1:54 pm, jq noob <sammil...@alliancecom.net> wrote:
> I am trying this and it does not work
>
> <input type="radio" name="<%variable%>" value="1">
> <input type="radio" name="<%variable%>" value="2">
>
> $(document).ready(function(){
>         $(':radio').dblclick(function(){
>                 $(this).attr('clicked', false);
>         });
>
> });
>
> It seems that I should be using ~ $(this).attr('checked', false); ??
>
> Thanks
>
> On Jan 8, 9:17 am, Eric Garside <gars...@gmail.com> wrote:
>
> > > And if the same page contains INPUT elements with the same name either
> > > inside another form or outside of any form?
>
> > Then you made a poorly coded page. :P The only reason to have a "name"
> > is so you can do something with the form data after submitting it. I
> > assumed he was going to key off the name. Using the name isn't really
> > a good idea. Like, ever. But he didn't ask how to recode his page, he
> > asked how to rewrite his function using jQuery mentality. Which I did.
>
> > > It seems like a good idea
> > > to use - obj.form - to restrict the context of the search, and even if
> > > not necessary with the mark-up actually being used the restricted
> > > search should still be quicker.
>
> > Oh, absolutely. To be honest, the best way to do this is to not use
> > names at all, but make use of IDs. And, never, ever use inline events.
> > Here is the current HTML:
>
> > <input type="radio" ondblclick="javascript:uncheckRadio(this);"
> > name="<
> > %=variable%>" value="1" >
> > <input type="radio" ondblclick="javascript:uncheckRadio(this);"
> > name="<
> > %=variable%>" value="2" >
>
> > This should go to:
>
> > <input type="radio" name="<%variable%>" class="unclick" value="1">
> > <input type="radio" name="<%variable%>" class="unclick" value="2">
>
> > Now, I'm not sure what your goal is here. Is it to have any radio
> > button on the page uncheck when you double click it? If so:
> > $(':radio').dblclick(function(){
> >     $(this).attr('clicked', false);
>
> > });
>
> > Is all the code you need. If you only want a select few radio buttons
> > to have this functionality, use a more restrictive selector.
>
> > $('.unclick:radio').dblclick(function(){
> >     $(this).attr('clicked', false);
>
> > });
>
> > On Jan 8, 9:46 am, Henry <rcornf...@raindrop.co.uk> wrote:
>
> > > Eric Garside wrote:
> > > > $('input[name="' + obj.name + '"]').attr('checked', false);
>
> > > <snip>- Hide quoted text -
>
> > - Show quoted text -

Reply via email to