The core is to use replace to replace the image path of img src to achieve switching of images of different sizes.
The animation below shows the size switching. Click the "Large Image" button to change the src of the image, load the large image, and click the "Small Image" button to display the small image again.
A brief explanation of how to use replace:
I am actually a novice too, so I don’t understand Haihan well.
String.replace(a,b); refers to replacing the part of the string containing a with b, for example, the string obj="welcome to my website!"; obj.replace("my","jb51net "); refers to using the string jb51net to replace my in the string obj.
If you are interested, you can use the following code for testing: