Gnats are attracted to vinegar, and for this reason it is commonly used to trap and kill these unwanted insects. Add a drop of liquid soap to the vinegar to break its surface tension. With this method, the gnats drown when they attempt to land.
Prepare a vinegar trap by pouring a small amount, enough to cover the bottom by 1/2 an inch, into a cup or bowl. Seal the cup tightly with plastic wrap and punch small holes in it. Make the trap with a paper or plastic cup for easy disposal. Gnats lay eggs on rotting fruit, and are attracted to vinegar because of its fermentation products.