When current travels through a wire, a magnetic field, made of lines of force, is formed around the wire. This called electromagnetism . If the wire is coiled, the lines of force link with each other.
Magnetic lines of force.
The result is a magnetic field with the same shape as the field surrounding a bar magnet. The strength of the field is determined by the number of turns and the current through the coil.
The field can be concentrated by placing a steel or iron CORE in the centre of the coil.
This is called an ELECTROMAGNET or SOLENOID.
If a soft iron core is used, it becomes only temporarily magnetised when the current is switched on, losing its magnetism when switched off.
This effect is used in bells and buzzers, and in scrapyards for shifting metal scrap around.
The field has a North and a South pole. It obeys the same rules as a bar magnet. Like poles repel each other, unlikes attract.
Electromagnets can react with bar magnets. This effect is used in loudspeakers, moving coil meters etc