New Style image carousel effects and javascript styles Based on javascript
This article provides examples of how javascript achieves image carousel effects for your reference. The specific content is as follows:
I. Implementation results
For example:
1. images are automatically rotated in turn. Each rotation is made to an image. The corresponding small icon appears with a red border and the corresponding image name is displayed.
2. When you place the cursor over a large image, the image rotation stops and the current image is always displayed. After you move the mouse away, the image continues to rotate.
3. When you move the cursor over a small icon, the large image area will display the corresponding large image. If you move the cursor away, the rotation will continue from the current image.
Ii. Code
<! DOCTYPE html>
Iii. Rotating debugging notes for multiple images
Js source code:
// Implement var num = 0 for rotation of several images; // the serial number of the displayed image. At the beginning, it is the first image function changeImg1 () {var arr = new Array (); arr [0] = ".. /images/hao123/7.jpg"; arr [1] = ".. /images/hao123/8.jpg"; arr [2] = ".. /images/hao123/9.jpg"; var photo = document. getElementById ("topPhoto"); if (num = arr. length-1) num = 0; // if the last image is displayed, the image serial number is changed to the first serial number else num + = 1; // The image serial number plus a photo. src = arr [num];} setInterval ("changeImg1 ()", 5000); // call the changImg1 () function every 5000 milliseconds
HTML code:
It is best to define a style when using it to unify the length and width of the image, so that the dynamic display of the image will be better.
The above is all the content of this article, and I hope it will help you learn javascript programming.
Articles you may be interested in:
- Js image carousel (5 images)
- Code for Implementing Image carousel using native javascript
- JS Code with left and right arrows for image carousel
- Simple js image rotation code (js image rotation)
- Js Image Automatic carousel code sharing (js image carousel)
- JS method for achieving simple image carousel Effect
- Native js and jquery achieve image carousel Special Effects
- Native js and jquery achieve image rotation fade-in and fade-out
- JavaScript image carousel code sharing
- Code sharing of js fade-in and fade-out image carousel Effects