Right from the docs
http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_check.2Funcheck_an_input.3F

$("input[name='veggies']").attr("checked", "checked");




On Oct 16, 9:25 am, GARIL <[EMAIL PROTECTED]> wrote:
> I used     $(":checkbox").each(function()
> {this.checked=this.name=="veggies"})   but I'm wondering if there's
> another way, like using filter perhaps?
>
> On Oct 16, 8:06 am, GARIL <[EMAIL PROTECTED]> wrote:
>
> > Using jQuery, is there a quick way of setting the 'checked' attribute
> > to true for all the 'veggies' below?
> > Thank you.
>
> > <form name='store'>
> > <input type="checkbox" name="veggies" value='2'>Banana
> > <input type="checkbox" name="veggies" value='1'>Avocado
> > <input type="checkbox" name="veggies" value='0'>Apple
> > <input type="checkbox" name="veggies" value='3'>Papaya
> > <input type="checkbox" name="veggies" value='4'>Plum
> > <br>
> > <input type="checkbox" name="fruits" value='a'>Broccoli
> > <input type="checkbox" name="fruits" value='b'>Cabbage
> > <input type="checkbox" name="fruits" value='c'>Radish
> > <input type="checkbox" name="fruits" value='d'>Squash
> > <input type="checkbox" name="fruits" value='e'>Cucumber
> > </form>

Reply via email to