Parents are unable to do this because the court will dismiss their case before it even gets to the substantive issues. All states, except Massachusetts and Vermont, and the District of Columbia are signatories to the Uniform Child Custody Jurisdiction and Enforcement Act. The UCCJEA is a uniform set of laws that harmonizes the jurisdictional rules regarding child custody agreements.
The court will not decide a case unless it has jurisdiction. Usually by virtue of filing the action, the court will have jurisdiction, not in child custody disputes. In response to parents shopping around the states for the most favorable court systems, the states accepted the UCCJEA as a way to prevent this behavior. It ensured that children be allowed to stay in their familiar homes.
Before the court decides the outcome of a child custody dispute, it will look to see if any of four conditions are in place. These conditions are listed in order of importance. If a condition is not met, the court will consider the next conditions. The more conditions the child satisfies, the more likely the court will rule on the matter.
First the court will determine if it is the home state of the child. This means that the child has lived in that state at least six months prior to the filing of the lawsuit.
Second, the court will look into the child's connections with the state. Specifically the court will inquire regarding friends, family, school, sports and other activities that show a consistent pattern of connection to the state.
For parent fleeing domestic violence situations, going to familiar places isn't always an option. In these situations, the court will assert jurisdiction if the parent can show that they were escaping an abusive situation.
Finally, if the child does not meet any of the three previous conditions the court may still assert jurisdiction because no other state can.
If you are in a child custody dispute then you may want to consult with a lawyer. There are multiple levels to these cases. For example, this is only dealing with the court's ability to decide on the matter. At this point, the court has not even heard substantive issues regarding custody. An attorney can walk you through the process to ensure that you get fair treatment.