Captain Underpants

 Captain Underpants  is a series of books written and illustrated by Dav Pilkey and published in 12 volumes by Scholastic from 1997 to 2015. Two boys, George Beard and Harold Hutchins, use a 3D Hypno-ring to hypnotize their principal, Mr. Krupp, into thinking he's a superhero called Captain Underpants, but then they make the mistake of pouring water on his head to bring him back to normal. This results in him slipping back and forth between trance and reality whenever he hears the sound of fingers snapping.

Book 5 reveals an error in the Hypno-ring: when used on women, it causes them to do the opposite of what they are told. When subjected to it, Ms. Ribble tuns into Wedgie Woman, but later turns nice when it's used on her again.

In Book 8, evil versions of George and Harold kidnap Sulu (the pet hamster of Melvin Sneedly) and Crackers (a pterodactyl the boys had found during a bout of time travel) and hypnotize them to be evil. The ray has no effect on Crackers (who, in a later book, his revealed to be female), but Sulu instantly turn evil and turns against the good George and Harold. By the end of the book, however, the boys get him back to normal.