Ammonia is collected in the inverted positioned glass jar by downward displacement of air as it is :
Lighter than air
Ammonia is collected in the inverted positioned glass jar by downward displacement of air as it is lighter than air. The density of ammonia is 0.73 kg/m3 which is lower than the density of air which is around 1.225 kg/m3. Therefore, it will rise up in the inverted glass container in which it is collected.
Note: When we say ammonia gas here we are referring to ammonia gas which is passed through quicklime CaO and does not contain any moisture. In case ammonia gas contains moisture it would be heavier than air and hence it will not rise up in the inverted glass jar container.