Is this how you do it?

I've been noticing alot of gnats in my apartment and I've read to put Apple cider vinegar with a few drops of dish soap in a jar with holes on the top is this how you do it?