Yes!

If the electrons were not attracted to their own positive nuclei then they would just fly off and atoms would not exist. By attracting to both nuclei, the electrons can be shared between the atoms, forming a covalent bond.