Behavior of NaCl in water with electrodes
$\ce{NaCl}$ once in water dissociates, producing $\ce{Na+}$ and $\ce{Cl-}$ ions. Note: this process is possible only because immediately after dissociation ions are solvated by water, i.e. water molecules bind to ions 



This is releasing energy and increasing effective size of ion, decreasing ion charge density. Once relatively free ions are produced, they can move between electrodes, transferring charge between electrodes. On electrodes ions may discharge taking/giving up electrons, and this is what usually happens with $\ce{Cl-}$ ion. However, if this is not an option, as the expected product is no stable enough in water, water molecule may react instead, producing another ion and either hydrogen or oxygen. This is what happens with $\ce{Na+}$: $\ce{Na}$ is too active to be stable in contact with water, so instead of sodium, hydrogen and $\ce{{}^{-}OH}$ are produced instead, resulting in  net reaction (assuming cold solution) $\ce{2NaCl + 2 H2O &lt;=&gt; 2 NaOH + Cl2 + H2}$ with chlorine and hydrogen released on different electrodes.