Code for your example (just tested):
$("[EMAIL PROTECTED]").each(
// For each button, run this code. The "i" is the loop
iteration index on
the current element
function( i ){
// Bind the onclick event to alert the iteration index
value
$( this ).bind(
"click",
function(){
alert( "You Clicked Index #: " + i );
}
);
}
);
The code that Josh just posted works too, if you don't need an index.
BTW, welcome to jQuery.
________
SEAN O
http://www.sean-o.com
Sean O wrote:
>
> Brad,
>
>
> Looks like you need to use the .each function to iterate through each
> radio button.
>
> Here's some demo code:
> http://www.bennadel.com/blog/534-The-Beauty-Of-The-jQuery-Each-Method.htm
>
> Docs:
> http://jquery.bassistance.de/api-browser/#eachFunction
>
>
> ________
> SEAN O
> http://www.sean-o.com/
>
>
>
> Brad Perkins-2 wrote:
>>
>> I'm new to jQuery. I'm trying to bind a function to a group of radio
>> buttons.
>>
>> For example,
>>
>> $("[EMAIL PROTECTED]").bind("click",
>> function() {
>> alert ('radio button clicked');
>> }
>> );
>>
>> should run the function anytime a radio button named 'rb' is clicked
>> but isn't working. Am I approaching this the wrong way, or is my
>> jQuery syntax wrong?
>>
>> Thanks,
>>
>> Brad
>>
>> _______________________________________________
>> jQuery mailing list
>> [email protected]
>> http://jquery.com/discuss/
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Bind-event-to-radio-button-group-tf3336101.html#a9278351
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/