Each object has a certain value that defines whether it will lose electrons when rubbing against an object with a higher value, and vice-versa. Glass can loose electrons much more easily than other objects, making it a useful tool for teaching about static electricity. Electrons are held in place by the positive balance of protons.
"Different materials have different affinities for electrons. By rubbing a variety of materials against each other and testing their resulting interaction with objects of known charge, the tested materials can be ordered according to their affinity for electrons. Such an ordering of substances is known as a triboelectric series. One such ordering for several materials is shown in the table at the right. Materials shown highest on the table tend to have a greater affinity for electrons than those below it.
Subsequently, when any two materials in the table are rubbed together, the one that is higher can be expected to pull electrons from the material that is lower. As such, the materials highest on the table will have the greatest tendency to acquire the negative charge. Those below it would become positively charged."
Links for info: physicalclassroom