An electric current has the ability to produce a magnetic field in a plane perpendicular to the direction of current flow. The electromagnet uses this principle. An electromagnet can be defined as a magnet which functions on electricity. Unlike a permanent magnet, the strength of an electromagnet can be changed by changing the amount of electric current that flows through it. If the current flow is cut, the property of magnetism ceases to exist.

But this is also an advantage of the electromagnet over a permanent magnet because controlling the electric current also controls the magnetic field, in this case, i.e., the strength of electric field controls the strength of magnetic field also. In fact, the poles of an electromagnet can even be reversed by reversing the flow of electricity.

More Info: en.wikipedia.org