In an action to recover the possession of personal property judgment for the plaintiff may be for the possession, or the value thereof in case a delivery cannot be had, and damages for the detention thereof. If the property has been delivered to the plaintiff and defendant claims a return thereof, judgment for the defendant may be for a return of the property, or the value thereof in case a return cannot be had, and damages for taking and withholding the same.