A modification of hat functions (MHFs) is considered for solving a class of nonlinear fractional integrodifferential equations with weakly singular kernels, numerically. Some preliminaries of fractional calculus are given. Properties of MHFs are presented and the fractional order operational matrix of integration is introduced. An estimation of the error is provided when a function is approximated by MHFs. To suggest a numerical method, the main problem is converted to an equivalent Volterra integral equation of the second kind and operational matrices of MHFs are used to reduce the problem to solution of some polynomial equations in two variables. Finally, illustrative examples are provided to confirm the accuracy and validity of the proposed method.