1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
   | $("#categories").change(function(){
	var objParent = $(this).parents("fieldset"),
		objsInput = objParent.find("input[type='checkbox']"),
		objsLabel = objParent.find("label[for]"),
		boolChecked = $(this).prop("checked");
 
	objsInput.prop("checked", boolChecked);
 
	if (boolChecked){
		objsLabel.removeClass("ui-checkbox-off").addClass("ui-checkbox-on");
 
		$.each(objsLabel.children(), function(i, item){
			$(item).children().each(function(j, jtem){
				if (j == 1){
					$(jtem).removeClass("ui-icon-checkbox-off").addClass("ui-icon-checkbox-on");
				}
			});
		});
	} else {
		objsLabel.removeClass("ui-checkbox-on").addClass("ui-checkbox-off");
 
		$.each(objsLabel.children(), function(i, item){
			$(item).children().each(function(j, jtem){
				if (j == 1){
					$(jtem).removeClass("ui-icon-checkbox-on").addClass("ui-icon-checkbox-off");
				}
			});
		});
	}
}); | 
Partager