It works like magnets, and in fact, electricity creates a magnetic field, in which similar charges repel each other and opposite charges attract. This means that if you put two negatives close together and let them go, they would move apart. The same is true for two positive charges. But if you put a positive charge and a negative charge close together, they would pull towards each other. A short way to remember this is the phrase opposites attract likes repel.