And just like opposite ends of magnets attract each other, so do opposite atoms. A negative atom will attract a positive one. When you rub a comb or plastic ruler, you're taking electrons away from the atoms in the comb. So the comb becomes positive - there's more protons than electrons. If you then put the comb near something negative, it will be attracted to it.
Water is a special material.
As I've already said, most things are balanced - with equal numbers of electrons and protons, so they wouldn't be attracted to the comb. But water is different. Water is made up of two different atoms called oxygen and hydrogen. When these two atoms join together, they share their electrons. This is often how things join together, by sharing electrons.