The polarity of an electromagnet can be changed by changing the direction of electric current through it.