When you comb your hair with a nylon comb, both the comb and your hair become charged. The comb and your hair acquire opposite charges. Because the individual hairs acquire the same charge, they repel each other. Perhaps you noticed that after running the nylon comb through your hair, the hairs on your head stood on end. This is a result of your hairs repelling each other because they are charged.
Static electricity is more of a problem when humidity is low.
When humidity is high, most surfaces are coated with a thin film of water. When objects coated by a film of water are rubbed together, the water prevents electrons from jumping between the objects.