An electronic device having retractable hanger includes a housing, a display panel, and a hanging mechanism. The display panel is mounted on the housing. The hanging mechanism is arranged in the housing. The hanging mechanism includes a base, a hanger, a movable member, and at least one resilient member. The base is secured in the housing. The hanger slides relative to the base and defines a hanging hole, a groove with corners, and protrusions by each corner. The movable member includes a first end and a second end, wherein the first end is rotatably connected to the base and the second end slides in the groove of the hanger.