This is a legitamate question. If one atom wants to lose an electron and another wants to gain an electron why don't they just transfer the electrons and just part ways?
If a Na+ ion and Cl- ion exist as NaCl,(ionic) it doesn't mean that, that particular Na donated electron to Cl. Na may lose electron somewhere else and Cl may gain electron somewhwere else. The main point of existence as Na+Cl-, ie NaCl is the electrostatic attraction between them.
To add on to @Jayanth Psy 's answer, ypu should also consider ionization energy and electron affinity. In the case of NaCl, sodium can't just lose its valence electron, it must be excited into ionisation (because of effective nuclear charge) and the electron must transfer to the chlorine. So you can't just transfer electrons because of this, without having some sort of electrostatic attraction and energy flow.
Ionic bond is not a bond in real. It’s just a force attraction between two ions placed closely. It’s something similar to the van der Waals’, but it has a lot of physical significance. Many have this query and I have seen a lot troubling on ionic bond. So no transfer or such thing takes place. Only attraction to hold them tight. This is all about ionic bond.