In this article, an N-rich covalent organic framework (COFTFPB-TZT) was successfully synthesized using 4,4′,4′-(1,3,5-triazine-2,4,6-triyl) trianiline (TZT), and 4-[3,5-bis (4-formyl-phenyl) phenyl] benzaldehyde (TFPB). The as-prepared COFTFPB-TZT possesses irregular cotton wool patches with a large specific surface area. A novel selective electrode based on COFTFPB-TZT was used for the determination of Mercury ions. The abundance of N atoms in COFTFPB-TZT provides more coordination sites for Hg2+ adsorption, resulting in a change in the surface membrane potential of the electrode to selectively recognize Hg2+. Under optimal experimental conditions, the ion-selective electrode shows a good potential response to Hg2+, with a linear range of 1.0 × 10−9∼1.0 × 10−4, a Nernst response slope of 30.32 ± 0.2 mV/-PC at 25°C and a detection limit of 4.5 pM. At the same time, the mercury-ion electrode shows a fast response time of 10 s and good reproducibility and stability. The selectivity coefficients for Fe2+, Zn2+, As3+, Cr6+, Cu2+, Cr3+, Al3+, Pb2+, NH4+, Ag+, Ba2+, Mg2+, Na+, and K+ are found to be small, indicating no interference in the detection system. The proposed method can be successfully applied to the determination of Hg2+ in 3 typical environmental water samples, with a recovery rate of 98.6–101.8%. In comparison with the spectrophotometric method utilizing dithizone, the proposed method is simple and fast and holds great potential application prospects in environmental water quality monitoring and other fields.