Theory:

Action of magnets:
When two magnets are moved close to each other, they either attract or repel each other.
The opposite poles of magnets attract, whereas the similar poles of magnets repel when they are pulled towards each other.
The attraction or repulsion of the magnets depends on the direction of the poles facing each other.
 
magn.png
Attraction or repulsion of the magnets
Repulsion occurs when like poles (N-N or S-S) of the magnets are kept closer to each other.
Attraction occurs when unlike poles (N-S or S-N) of the magnets are kept closer to each other.
Like poles repel whereas unlike poles attract each other.
Loss of magnetic property:
The magnetic property of a material will be lost when
  • heated,
  • hammered, or
  • dropped from a certain height.
10.svg
Heating a magnet
 
9.svg
Hammering a magnet
 
8.svg
Dropping a magnet
 
Placing the magnets near an electronic device and improper storage will also affect the magnetic field of a magnet.