In an ionic bond, they dont actually share electrons. Instead, one element gives off an electron and the other takes one. This creates 2 differently charged ions which brings them together. In the covalent bond (H20) Oxygen has 6/8 electrons in its valanced shell. Therefore needing 2 more to satisfy it. Two hydrogens do the trick pretty well. The hydrogen still needs an electron so they share the electrons creating a covalent bond.
Hey, very cool :) Can I ask you something? I'm not very good ad chemistry, so I wonder that isn't the first (the upper one) process a reduction-oxidation reaction since they share electrons?