This is an example of charging by induction. Details follow...
The most common type of capacitor consists of two parallel plates placed a short distance apart. We then run wire to connect one plate to the negative terminal of a battery, and the other plate to the positive terminal.
Since the capacitor plate is at higher potential than the negative terminal of the battery, electrons will move from the battery onto the plate (a current will exist).
As negative charge arrives on this plate (the bottom plate in the diagram below), its presence induces electrons to move off the top plate, and flow toward the battery, with the result that the top plate becomes positive in charge.
(Note that in the diagram, "conventional current" is shown, which is the direction positive charge would be moving, if it was the charge carrier. In fact, electrons are moving in the opposite direction!)
As this movement of charge continues, the difference in potential between the two plates of the capacitor increases. This will continue until this potential difference becomes equal to the voltage of the battery being used to charge the capacitor. Then, all flow of charge from the battery will cease.
The capacitor is now fully charged, with a voltage equal to that of the battery.
The charge on each plate will be equal in size, but of opposite type. This means the net charge is zero!
The capacitor still stores energy however, because the negative charge is on a plate at low potential, while the positive charge is at high potential. Both these situations result in charges having high potential energy.
It is important to understand that current can only exist in a path that contains a capacitor as long as the voltage across the capacitor plates is changing. Once the capacitor voltage becomes constant, no further current can exist. Thus, a capacitor will block a DC current, but allow AC to pass through.
Also, you should realize that no charge actually flows through the capacitor. If this were to happen, the device is said to have suffered dielectric breakdown, and it must be replaced.
Please see the explanation.
Start with the equation:
Please notice that the only fixed value is the capacitance, C. Also, observe that the other two values, the charge on the plates, Q, and the voltage across the capacitor, V, can be varied of time.
Differentiate these two variable with respect to time.
We know that
We can solve this differential equation, using the separation of variables method:
Integrate both sides:
Equation shows how the voltage across the capacitor depends the incremental sum of the current flowing into the capacitor and equation  show how the charge on the capacitor is proportional to the voltage across the capacitor.