var checks = {"1503":"1503","1498":"1498","1508":"1508","1454":"1454","1505":"1505"}; $(document).ready(function(){ for (item in checks) { if ($("#C" + item)) $("#C" + item).removeClass("fa-heart-o").addClass("fa-heart"); } $("#myCounter").html('(5)') });