For magnetic domain imaging, with a very high spatial resolution magnetic force microscope, the tip-sample distance should be as small as possible. However, magnetic imaging near the sample surface is very difficult with conventional magnetic force microscopy (MFM) because the interactive forces between the tip and sample include van der Waals and electrostatic forces along with a magnetic force. In this study, we proposed alternating MFM which only extracts a magnetic force near the sample surface without any topographic and electrical crosstalk. In the present method, the magnetization of an FeCo-GdO superparamagnetic tip is modulated by an external AC magnetic field in order to measure the magnetic domain structure without any perturbation from the other forces near the sample surface. Moreover, it is demonstrated that the proposed method can also measure the strength and identify the polarities of the second derivative of the perpendicular stray field from a thin film permanent magnet with a DC demagnetized state and remanent state.