A time-discontinuous Galerkin (TDG) finite element method for analyzing the dynamic response of cantilever beam subjected to moving force or moving mass is presented. The cantilever beam is discretized in space by finite element method, and the time-varying dynamic equations are derived. The TDG finite element method by which both the displacements and velocities are approximated as piecewise linear functions in time domain and discontinuous at the discrete time levels is adopted to solve the differential equations. This method inherits third order accuracy and the unconditionally stable behavior, moreover, it is endowed with large stability limits and controllable numerical dissipation. The numerical solutions are accord with analytic ones, which validates the feasibility and superiority of this method for solving the dynamic response of cantilever beam under moving force or moving mass.