A series of discoveries in the late 1700's/early 1800's around magnetic fields led to the development of early electromagnets. Hans Christian Oersted discovered in 1820 that if you pass an electrical current though a wire it would create a magnetic field. Dominique François Jean Arago discovered soon after that if you took a steel rod you could pass it into wrapped wire from an electromagnet: The steel would then become magnetized. Then William Sturgeon invented what turned into the modern electromagnet. He discovered leaving steel in the coiled wire made a much stronger magnetic field.
HERE IS THE ELECTROMAGNET IN ACTION! Of course its just a D battery so I just picked up a chunk of staples. I used some plastic to hold the battery and wires in place: however that was just to take a picture. Its a small enough electromagnet to handle with your bare hands. THE BATTERY WILL HEAT UP SLIGHTLY. DO NO LEAVE IT PLUGGED IN FOR A LONG TIME.
This is a very small example of an electromagnet. With a technology that can be so dangerous: It's important to start small and scale up slowly. Nottice electromagnet produces HEAT at the source. Start thinking about how you could hold the battery and wires in place safely. How could you switch the electromagnet on at a distance?