You'll want something like this:
window.addEvent('domready', function(e) {
$$('div.option-radios label.radio').each(function(label, i) {
label.addEvent('click', function(event) {
event.target.toggleClass('selected');
});
});
});
Note that this uses the Array.each
method instead of Array.some
. The latter doesn't do what you expect. It then registers a click
event on every label which simply toggles the selected
class on the event target.
Then you can add other initialization code to the each
loop and more logic to the click event handler.
I also used the domready
event which is usually preferred over load
since it fires earlier.
Here's a fiddle to play around with.