var checks = {"1445":"1445","3432":"3432","3419":"3419","1441":"1441","1452":"1452"}; $(document).ready(function(){ for (item in checks) { if ($("#C" + item)) $("#C" + item).removeClass("fa-heart-o").addClass("fa-heart"); } $("#myCounter").html('(5)') });