with this code : http://jsfiddle.net/oreli/7wdq6ktn/
I like to have the following behavior:
but I still have all red or green.
What is my mistake?
thank you
$(document).ready(function () {
$( ".choice" ).each(function() {
if($(".orderChoice").is(":disabled")) {
$(".choice").addClass('disabled').remove('notdisabled');
} else {
$(".choice").addClass('notdisabled').remove('disabled');
};
});
});
You are selecting all the .choice
and applying the class. Use context:
$(document).ready(function () {
$( ".choice" ).each(function() {
if($(this).find("input").is(":disabled")) {
$(this).addClass('disabled').remove('notdisabled');
} else {
$(this).addClass('notdisabled').remove('disabled');
};
});
});
Fiddle: http://jsfiddle.net/7wdq6ktn/2/