First question - are you referring to an automatic transmission for the 4WD?
If an automatic - there are two models for the 1996; so check the Transmission code 42RE; 4 Speed
or Transmission code 44RE; 4 Speed.
For the 1998 model year, there is one (1) automatic transmission, so again check the specific transmission codes: 42RE; 4 speed
If the transmission models are the 42RE - then they will interchange from the 1996 5.2L V8 to the 1998 4.0L inline six cylinder engine.
Be sure to always replace the individual transmission mounts - due to mileage and wear, and also check the driveshaft and u-joints for wear - when changing the transmissions.
Try these various on-line vendors - to list only a few:
These same transmission mounts fit (interchange) between the Jeep Cherokee (and Grand) model years 1984-2000 and 1996-1998;
Transmission mount (crossmember) = PIONEER part # 622625 - or it's equivalent
Transmission mount (rear) = ANCHOR part #2828 - or it's equivalent