Top to the jar makes is specific that you want the lid that belongs to that particular jar. Top of the jar could mean the upper-most part of the jar itself. Either works if you mean "lid".
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.