Highly orientated Co-doped Zn(Mg, Cd)O thin films have been prepared on Si (001) substrate using pulsed laser deposition (PLD). Our results indicate that Mg and Cd-doping can tune the bandgap of ZnO thin film. Apparent room-temperature ferromagnetism is observed in these films, which can be modified by the bandgap of ZnO. A narrow bandgap enhances the ferromagnetism of the films through the Cd-doping, and wide bandgap does the opposite through the Mg-doping, which may be ascribed to the ferromagnetic (FM) exchange interaction between the 3d states of magnetic Co ions and the impurity band. These experimental results provide some new evidence that the ferromagnetism in Co:ZnO is closely related to crystal defects and improve our knowledge about ferromagnetism in dilute magnetic oxides.