Yes, that works great. It's also easier not having to list all the image names. The n is far easier.
One question. Should the JS have a closing curly bracket just before the </style> tag? It seems to work fine with / without.

<style>
#img0 {
transform: scale(100%);
transition: all 1s ease-in;
}
#img0.scale {
transform: scale(105%);
</style>