All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
First of all, you should know that the religious ruling is that the woman who is divorced from her husband has more right in the fostering of her children than their father if they are less than seven years of age. When they reach seven years they are given the choice either to be with their father or mother, and they will stay with whoever they choose. Before the age of seven, the child stays with his/her mother as long as she does not remarry. If she remarries, she loses the right of fostering them as the Prophet said to a woman: "You have more right in fostering your child than your husband as long as you do not remarry." [Ahmad]
The majority of scholars are of the view that the relatives who have more right in the fostering of the children after their mother are as follows: the mother of the mother [i.e. the grandmother of the child from the mother's side], then the father, then the mother or grandmother of the father, then the grandfather [father's side], then the mother [or grandmother] of the grandfather, then the sister, then the maternal aunt, then the paternal aunt, then the daughters of his brothers, and finally the daughters of his sisters.
The female relative who comes in priority over others is the one who is from the same mother and father as the child, then the one who is from the mother's side only, then the one who is from the father's side only, and finally, the right of fostering will be for the other relatives by priority [the one who is closest to the child comes first].
This is in relation to the right of fostering, as regards spending on the child, then if the child has money, then the fostering will be from his money, otherwise it is those who are obliged to spend on him, and they are the child's father, then his grandfather.
In case the one to whom the right of fostering is given loses his eligibility because of her/his dissoluteness or her/his bad nurturing of the child, then the Muslim ruler will transmit the right of fostering to the one who deserves it after her/him.
Therefore, you should know that by remarrying, you lose the right of fostering your child.
Allaah Knows best.