Various changes occur in the myocardial infarcted microenvironment. An in-depth understanding of these changes has enabled the development of the functional hydrogels for cardiac repair. This article introduces recent advance in functional hydrogels for the treatment of myocardial infarction, including MMP-responsive hydrogels, ROS-scavenging hydrogels, immunomodulatory hydrogels, conductive hydrogels, vascularized hydrogels, and 3D printed hydrogels. Future perspective is also presented.