The short answer is, it depends. Most states and the District of Columbia follow the Uniform Child Custody Jurisdiction and Enforcement Act. The UCCJEA essentially harmonizes the various child custody jurisdiction rules among the states. So far, only Massachusetts and Vermont remain the black sheep in this otherwise harmonized system.
There are four conditions that a court can analyze to determine if it can assert jurisdiction over a child. These are listed in order of preference. The court will start with the first method and if it does not apply, then move onto the next one. If a child satisfies more than one method, that improves the likelihood the court will rule on the custodial matter.
First, the court will determine if it is child's home state. To become the home state of the child, he or she must have lived in the state for at least six months prior to filing legal proceedings.
If that test is not met, the court will next consider if the child has significant personal and familial contacts in the state. The court will consider if the child has any friends, classmates, teachers, coaches and family in the state. The more connections a child has, the more likely that the child is a true resident of the state.
Thirdly, the court will inquire if the child and parent fled to the state to avoid domestic abuse. The court will not punish parents for trying to escape a dangerous situation.
Finally, the court will assert jurisdiction if the moving party can show that no other state can meet any of the three above mentioned tests.
If you are engaged in a child custody dispute then you should consult with an attorney as soon as you can. No one may want to bring an attorney in but an attorney is a good person to have in your corner when you are trying to get custody over your children. An attorney can help you prepare your arguments and file the paperwork. An attorney will also have your back, you don't need to do this alone.