Home > Web Front-end > JS Tutorial > Switching between large and small images through replace string replacement under jQuery_jquery

Switching between large and small images through replace string replacement under jQuery_jquery

WBOY
Release: 2016-05-16 17:53:42
Original
1381 people have browsed it

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:

Copy the code The code is as follows:

var obj="welcome to my website!";
var newobj=obj.replace("my","jb51net's");
alert(newobj);

Okay, that’s all. More content to learn is on the example page.

Core code:
Copy code The code is as follows:



Package download addressjquery-replace-pic-convert.rar
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template