Question

I would like to style all of the radio buttons with the same name in a form easily in a nice Prototype or jQuery-style shortcut.

$('billship').select('name:shipType') or something like that.

Does such a shortcut for form field names exist?

Was it helpful?

Solution

With jQuery:

$('#billship input:radio[name="shipType"]');  
$('input:radio[name="shipType"]', '#billship');

Both are equivalent, but the 2nd one performs slightly better and I personally prefer it.

With Prototype, I believe it would look like this:

$$('#billship input[type="radio"][name="shipType"]');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top