FYI, the "rice trick" doesn't really work.
A slightly better option is to keep any of those silica packets that are in everything these days (the things labeled "Do not eat"). The purpose of them is to absorb moisture. If you have a wet phone or whatever, put it in a ziplock back with silica packets and hope for the best.
But your better bet is to not get your electronics wet. (Obviously, not controllable in the above case.)