Implant-associated infection (IAI) caused by pathogens colonizing on the implant surface is a serious issue in the trauma-orthopedic surgery, which often leads to implant failure. The complications of IAI bring a big threat to the clinical practice of implants, accompanied by significant economic cost and long hospitalization time. In this study, we propose an antibiotics-free strategy to address IAI-related challenges by using a biodegradable and cytocompatible hydrogel coating. To achieve this, a novel hydrogel system was developed to combine the synergistic effects of good cell affinity and antibacterial properties. The hydrogel material was prepared by modifying a photocross-linkable gelatinbased polymer (GelMA) with cationic quaternary ammonium salt (QAS) groups via a mild and simple synthesis procedure. By engineering the length of the hydrophobic carbon chain on the QAS group and the degree of functionalization, the resulting GelMA−octylQAS hydrogel exhibited an integration of good mechanical properties, biodegradability, excellent bactericidal activity against various types of bacteria, and high cytocompatibility with mammalian cells. When coated onto the implant via the in situ cross-linking procedure, our hydrogel demonstrated superior antimicrobial ability in the infective model of femoral fracture of rats. Our results suggest that the GelMA−octylQAS hydrogel might provide a promising platform for preventing and treating IAI.