Can a person leave the masjid to take a shower at home to get rid of the sweat and to change clothes?

Find answers

Yes, especially if the masjid does not have a washing facility.

It was narrated from A’isha (ra): “The Messenger of Allah (pbuh) used to put his head out of the masjid while he was performing i’tikaf, and I would wash it, while I was menstruating.” [Sunan an-Nasa’i]

Previous Can a Muslim celebrate and greet people on the Gregorian “New Year”?
Next Can I name my child Jibreel? and if not, what is the difference between naming after prophets and after angels?