Rubbing an object can cause it to build up an electrical charge in the object. This happens because the rubbing action can make one object pass electrons to the other. Which way the electrons travel is dependent on which materials you are rubbing together.
A loss of electrons makes an object positively charged,
a gain of electrons makes an object negatively charged.
Opposite charges attract, like charges repel.
So how does the balloon work? The charge built up on the balloon is the opposite to the charge of the surface that it sticks to.