They wouldn't stay on, of course. He is quite slim and swimming pants without working elastic band simply won't stay, not even for a while. Lucky thing is that the elastic band was loose, it wasn't sewn together with the seam. If it had, I could have used the same idea, I would have just left the old elastic band on its place and added the new one next to it.
Anyway, step one. Rip open the back seam, cut and remove the old elastic band. Take a safety pin, close it to the other end of the new elastic band and put the elastic band on its place with the help of the safety pin.
Once the elastic band is on its place, sew the ends together. If you have sewing maching, you can use it, if not, use needle and thread like this:
Of course, if you don't have any needle or thread but have new elastic band (you can rip one out of old worn out pants if you have those around), you can just tie a knot to it. Thicker of course, but at least the pants stay on!
Adjust the elastic band and it looks like this:
You can close the gap if you want to but if you are in a hurry, even that isn't necessary. The seam under the waist band will prevent the gap opening the whole way down. Of course, if you like neat finish (and don't have 4 year old waiting to go swimming as right now), use hide stitches to close the gap. No one will ever know you changed the broken elastic band.
Couple other early birds swimming too: