jack-in-the-box (n.)

also jack-in-a-box, 1560s, a name for a sharp or cheat, "who deceived tradesmen by substituting empty boxes for others full of money" [Robert Nares, "A Glossary of Words, Phrases, Names, and Allusions," London, 1905]. See Jack + box (n.1). As a type of toy involving a figure on a spring inside a box, it is attested by 1702. Also it has been used variously to mean "peddler who sells wares from a temporary stall" (1690s), "an unborn child," a type of gambling game, a hermit crab, a large wooden male screw, the sacrament, and various mechanical devices.