var checks = {"607":"607","3063":"3063","913":"913","3322":"3322","3032":"3032","175":"175"}; $(document).ready(function(){ for (item in checks) { if ($("#C" + item)) $("#C" + item).removeClass("fa-heart-o").addClass("fa-heart"); } $("#myCounter").html('(6)') });