An electromagnet can be created by wrapping a wire around a nail and attaching the two ends of the wire to a battery. What happens in an electromagnet?.