Wrap a rubber band around the cap or lid and then try to open it. The inability to get a firm grip is often the reason a cap is hard to open, and a rubber band will help you hang on. Most supermarkets carry rubberized jar and cap openers you can purchase. Place these over the cap and twist. Use rubber gloves to gain a better grip on stubborn caps. (Ref 1)
Submerge the cap in warm water. Avoid submerging the bottle or jar in the water as it may ruin the label. After about 10 minutes, try to open the jar again. Repeat if unsuccessful. (ref 1)
Tap the outside edge of the cap or lid on a hard surface such as a cutting board. This may break the seal and help to release the lid. (Ref 2)