The invention discloses antibacterial hydrogel, which is prepared from the following components: methacrylated chitosan and antibacterial microspheres, and the antibacterial microspheres are sodium alginate microspheres loaded with nano-silver, wherein a mass ratio of the methacrylated chitosan to the antibacterial microspheres is 10: (0.1-2). According to the preparation method, the nano-silver is loaded into the sodium alginate microspheres, so that the slow release of the nano-silver is realized. Meanwhile, the sodium alginate microspheres loaded with the nano-silver are added into the methacrylated chitosan hydrogel to form microsphere-containing antibacterial hydrogel, so that the antibacterial property of the material is greatly improved, the cytotoxicity of the nano-silver is reduced, and the release period of the nano-silver is as long as 10 days or longer. The antibacterial hydrogel disclosed by the invention is safe, non-toxic and good in antibacterial property, shows appropriate swelling and degradation behaviors, has excellent biocompatibility and mechanical properties, is biodegradable and bioabsorbable, and also has injectability and a hemostatic function.