var checks = {"1164":"1164","583":"583","2890":"2890","589":"589","594":"594"}; $(document).ready(function(){ for (item in checks) { if ($("#C" + item)) $("#C" + item).removeClass("fa-heart-o").addClass("fa-heart"); } $("#myCounter").html('(5)') });