What happens to the electrons of metal elements when forimg ionic compound with nonmetals?

Generally the electrons are transfered from the metal elements to the nonmetalic elements so that both form stable electron configurations. For example, in sodium chloride one sodium atom loses an electron so that it has the stable electron configuration of Neon and chlorine gains one electron so that it has the stable electron configuration of Argon. This results in negativley charged chlorine atoms and positively charged sodium atoms which are then attracted to each other and form the ionic bond. Having a lot of those atoms and therefore a lot of those bonds gives an ionic compound. Generally no bonds are fully ionic or covalent; they have what is called percent ionic character that is a measurement of how much the bond resembles an ionic bond rather than a covalent bond (in covalent bonds electrons are shared between the atoms).