An electromagnet is a type of magnet in which the magnetic field is produced by an electric current. The magnetic field disappears when the current is turned off. Electromagnets usually consist of a large number of closely spaced turns of wire that create the magnetic field.
Use a pair of wire strippers to remove a few centimeters of insulation from each end of the wire. Neatly wrap the wire around the nail. The more wire you wrap around the nail, the stronger your electromagnet will be. Make certain that you leave enough of the wire unwound so that you can attach the battery.