Electromagnets only produce magnetism when an electrical current passes through them. They usually consist of a metal core made of iron or a similar material, around which are wrapped many coils of thin insulated wire. The metal core becomes magnetized when an electric current passes through the wire coil, but the effect disappears immediately the current is shut off. Very powerful electromagnets can be created by using many coils and strong electrical currents.

Picture credit: google