Scalar-field dark matter models imply small oscillations of fundamental constants. These oscillations could result in observable variations of the magnetic field in a permanent magnet. We propose an experiment for detection of this type of dark matter through searches of oscillations of magnetic field of permanent magnets with a SQUID magnetometer or a low-noise radiofrequency amplifier. We show that this experiment may have comparable sensitivity to leading experiments searching for variations of fundamental constants in the range of frequencies from a few Hz to about 1 MHz. We also discuss applicability of the approach of variations of fundamental constants for accounting for the interaction with scalar dark matter.