Antifouling and antibacterial zwitterionic hydrogels were prepared and used as soft contact lens for ocular bacterial infections therapy. The zwitterionic hydrogels are mainly composed of zwitterionic segments and tuned by a small part of other hydrophilic and hydrophobic monomers for optimal properties, which achieve high transmittance of 94% in the range of visible wavelength, high water content, good water retention rate and stable dehydration-rehydration property. Moreover, even after five co-culture cycles with non-specific protein and bacteria, the zwitterionic hydrogels showed much better antifouling properties than the commercial contact lens (CL). Besides, functional monomer acrylic acid was incorporated in the zwitterionic hydrogels to load norfloxacin (NF) and control its release by molecular imprinting technology. Thus, the zwitterionic hydrogels have significant in vitro and in vivo bactericidal function. By constructing a conjunctivitis model of rabbits, we found that delivery of NF by the zwitterionic hydrogels had a better therapeutic outcome than delivery of NF through eye-drops. These results indicate that the zwitterionic hydrogels are competitive candidates for the application of wearing contact lens and ophthalmic drug delivery.