$(function(){ var s = $(".bx_filter_container"); s.each(function(indx, el){ $(el)[($(el).has(":checked").length ? "add" : "remove")+"Class"]("orange"); }); });