var checks = {"538":"538","543":"543","3478":"3478","1683":"1683","557":"557","3189":"3189","3181":"3181"}; $(document).ready(function(){ for (item in checks) { if ($("#C" + item)) $("#C" + item).removeClass("fa-heart-o").addClass("fa-heart"); } $("#myCounter").html('(7)') });