שֹׁפֵךְ דַּם הָאָדָם בָּאָדָם דָּמוֹ יִשָּׁפֵךְ כִּי בְּצֶלֶם אֱ־לֹהִים עָשָׂה אֶת הָאָדָם"He who spills the blood of man within man will his blood be spilled, for in the image of God he made man" (Bereishit 9:6). The phrase "man within man" includes the fetus inside a woman's body (Sanhedrin 57b). With this in mind, abortion is illegal in the whole world.
However, among Jews, the commandment against murder is a different one, found in the Ten Commandments. In addition, when a fetus endangers the live of his mother, then the live of the mother takes precedence, and abortion when carried out in this situation is permitted.
In short, abortion is also illegal in Judaism. However, it can be performed if necessary, like in the above scenario, some Poskim say, within the first 40 days since the woman immersed in a mikvah, others say, within the first trimester. One must consult with a G-d fearing Orthodox Jewish Rabbi for a heter before doing anything like this. Plus, once given permission, the woman may not go to a gentile doctor to perform the abortion, because all gentiles are bound by the prohibition of murder.
Wasting seed is a very serious transgression for Jewish men, and this applies to even boys below Bar Mitzvah. Apparently, Er and Onan, the sons of Yehuda who married Tamar, committed this sin (according to Rashi) while they were only seven years old. It is wise to talk to your sons below Bar Mitzvah about this transgression, as they are liable for this aveira.
For those Poskim who compare abortion to wasting seed, a Jewish woman who has a heter to perform an abortion to save her life, may not go to a Jewish male doctor. She must go to a female Jewish doctor instead, since a Jewish woman does not have the negative commandment of wasting seed.
All the information above, I learned from Mrs Iris Odani Elyashiv in her latest shiur that can be found here.