A latching mechanism to connect a cover to a housing includes a catch and a catching portion. The catch is disposed on the cover. The catch includes a latching end and a connecting portion. The catching portion is defined in the housing. The catching portion includes a first hole and a second hole communicating with each other. The first hole is larger than or substantially equal to the diameter of the latching end, the second hole is larger than the connecting portion and smaller than the latching end, and a joint of the first hole and second hole is smaller than the diameter of the connecting portion. The present disclosure further provides an electronic device including the latching mechanism.