Electromagnets are composed of a metal core wrapped with a coil of wire, called a solenoid. Electric current generates a magnetic field and creates an electromagnet when it passes through the wire. An electromagnet can only exert a magnetic force while electricity flows through the solenoid. Electromagnets turn off when the current is switched off.
The doorbell button is a switch that opens and closes the circuit. Pushing the button completes the circuit; electric current flows through the solenoid and turns on the electromagnet. The electromagnet attracts, or pulls, a metal striker, which hits a bell to make the doorbell sound. When the button is released, the circuit is interrupted and the electromagnet is turned off. A spring pulls the striker back.
Other electromagnetic doorbells use a plunger mechanism. A doorbell with a chime unit has an iron plunger with a plastic core. In the "off" position, the plunger is partially inserted in a solenoid. When the button is pushed, the electromagnet is turned on and the electromagnetic force pulls the plunger into the solenoid, which activates the chime unit.
Some newer doorbells contain an integrated circuit that activates a digital recording of a chime or other sounds when the doorbell button is pushed.