Your soul leaves the body and enters the container as the material of the spell, while your body is in a state of absentia. When the soul is in the container, you can perceive the surroundings as if you were in the container.
Magic Jar 5e
Casting Time: 1 minute
Components: V, S, M
Duration: Until dispelled
You cannot move, nor use reactions, and the only action you can do at this time is to project your soul out of the container up to 100 feet away, or return to your still alive body (and terminate the spell), or Try to occupy the body of another humanoid.
You can be attached to any humanoid creature you can see within 100 feet from you (the creature protected by the magical protection against good and evil or the protection circle cannot be possessed).
The target must make a Charisma save. If the saving throw fails, your soul enters the target’s body and the target’s soul is trapped in the container; if the saving saves succeeds, the target resists your possession, and you will not be able to try to possess the creature again for the following 24 hours.
After the possession is successful, the body of the target creature will be controlled by you. Your game data will be replaced with the creature’s attribute data, but you will retain your alignment and the attributes of intelligence, perception, and charm. Your class feature gains will also be maintained while possessing, but you cannot use any class features that the target may have.
In addition, the soul of the possessed creature can observe the outside from the inside of the container with its own senses, but it can neither move nor use actions.
When attached to a body, if the container is within 100 feet of you, you can return from the host’s body to the container with a single action, and let the host’s soul return to its own body.
While you are in the host’s body, if the host’s body dies, you must make a Charisma save against the spell save DC. When the exemption is successful and the container is not more than 100 feet away from you, you return to the container. If the saving throw fails, he will die immediately.
If the container is destroyed or the spell ends, your soul will immediately return to your own body. If you are more than 100 feet away from you or your body is dead when you try to return to your body, you will die with it.
If the soul of another creature is in the container when the container is destroyed, and the body of that creature is still alive and not more than 100 feet away from it, its soul will return to the body. Otherwise, the creature dies.
When the spell ends, its container will be destroyed.