Q: Can I leave the masjid during ittikaf to get dinner or change my clothes?
A: Ittikaf is invalidated by leaving the masjid without excuse or even intending to leave even if you do not.
It is not invalidated for leaving the masjid to use the restroom, bring food, attend Jumuʿah (which is required), or perform some obligatory purification, etc.
Source: Bidayat al-Abid