Modern inverters use oscillator circuits and semiconductors or transistors to revert current direction. When a current is run through a coil, a magnetic field is formed. When another coil is placed right next to the first one, the magnetic field from the first (primary) coil will force the current to flow into the second coil.
Source: https://www.australiandirect.com.au/12v-electronics/inverters/