For the first time, the magnetic force microscopy (MFM) is used to characterize the mechanically-exfoliated single- and few-layer MoS2 and graphene nanosheets. By analysis of the phase and amplitude shifts, the magnetic response of MoS2 and graphene nanosheets exhibits the dependence on their layer number. However, the solution-processed single-layer MoS2 nanosheet shows the reverse magnetic signal to the mechanically-exfoliated one, and the graphene oxide nanosheet has not shown any detectable magnetic signal. Importantly, graphene and MoS2 flakes become nonmagnetic when they exceed a certain thickness.