Since fleas are attracted to the heat produced by the nightlight, they are drawn toward it and get stuck on the tape or glue board lying on the floor underneath the light.
It's best to place a handful of these DIY traps at various places in your room unless it's a small space. Otherwise, fleas may find another heat source,