NEW DELHI — What happens in a northern Indian town when you rip up someone else’s plants and saunter away?

You go to jail. Even if you’re a donkey.

News this week that eight donkeys had been jailed for four days for eating expensive saplings went viral in India, drawing a mix of ridicule and good-hearted laughs.

The Indian government has been on a cleanliness kick, led by Prime Minister Narendra Modi, who has vowed to build tens of millions of toilets and clean up garbage in cities. According to the authorities, the donkeys were making a mess.

“We had warned the donkey owners a couple of times, but they didn’t pay heed,” said R.K. Mishra, a police constable, according to an interview that was broadcast on an Indian news channel.