An exemplary latching mechanism for connecting a first component (20) and a second component (40). The latching mechanism includes at least one first engaging portion (408) formed/defined on the second component, at least one latch holder (60a, 60b) fixed relative to the first component, and at least one first latching member (80a, 80b). A first latch-clasping piece (604) extends from the at least one latch holder. The at least one first latching member has at least one second engaging portion (806). The second engaging portion engages with the first engaging portion of the second component. The first engaging portion of the second component and the first latching member are disposed between the first latch-clasping piece of the latch holder and the first component. The present invention further provides an electronic device employing the latching mechanism.