A coil with an iron core
An electromagnet is a solenoid with an iron core. Current through the coil produces a field, which magnetises the core and strengthens the field. Soft iron is useful because it loses most of its magnetism when current is switched off. A switch therefore controls the magnetic effect. Small iron clips can demonstrate attraction, but the magnet is not attracting every possible material. The diagram is a controlled low-voltage investigation.