$('input.plan-select').change(function() {
// alert('Handler for .change() called.');
$(".subscription", this).toggleClass('selected');
});
Fiddle: http://jsfiddle.net/XPVVp/
It doesn’t toggle the class for some reason, I’m not sure why it isn’t working.
That’s because the
.subscriptionselect is not a child of theinputelement which is how your code is written. Instead the.subscriptionelement is a parent so you need to use the right jQuery operations to find the proper parent like this:.closest()will look up the parent chain until it finds the first parent that matches the selector.Working demo here: http://jsfiddle.net/jfriend00/krTER/