Biological cell membranes can efficiently switch Na+/K+ selectivity in response to external stimuli, but achieving analogous functions in a single artificial membrane is challenging. Here, we report highly crystalline covalent organic framework (COF) membranes with well-defined nanochannels and coordinative sites (i. e., amino acid) that act as ion-selective switches to manipulate Na+ and K+ transport. The ion selectivity of the COF membrane is dynamic and can be switched between K+-selective and Na+-selective in a single membrane by applying a pH stimulus. The experimental results combined with molecular dynamics simulations reveal that the switchable Na+/K+ selectivity originates from the differentiated coordination interactions between ions and amino acids. Benefiting from the switchable Na+/K+ selectivity, we further demonstrate the membrane potential switches by varying electrolyte pH, miming the membrane polarity reversal during neural signal transduction in vivo, suggesting the great potential of these membranes for in vitro biomimetic applications.