We investigate the structural, electronic properties of MX$_2$. (M=Ti, V, Cr, Zr, Nb, Mo, Hf, Ta, W) (X=S, Se) and their phase transition. We calculate the relative stability of two phase structures (octahedral-T and trigonal-H) determined by considering relative positions of X. We find interesting phase existence for the each group in the periodic table. The stable phase structure of IV-group (Ti, Zr, Hf) is octahedral, while VI-group (Cr, Mo, W) is trigonal, and V-group (V, Nb, Ta) is possible two phase structures. Two phase structures of MX$_2$ have a same total energy at the same lattice constant near the each most stable lattice constant. From these results, we also study activation energy barriers at the various lattice constants such as from stable T phase to H phase, same total energy, and from stable H to T. Interestingly we find that the activation energy barrier is small at the small and large lattice constants for the stable lattice constants. It means that the phase transition occurs by compressive and tensile strains.