This JavaScript code allows you to display and switch images in a slider on your web page. You can download the necessary files and follow the instructions below to integrate this slider into your project.
-
Download the
script.js
,style.css
, andindex.html
files. -
Place the files in your project structure as follows:
/css/style.css /js/script.js /images/img-1.jpeg /images/img-2.jpeg /images/img-3.jpeg /index.html
-
Open the
index.html
file in your preferred web browser. -
View the images by clicking the "Next" and "Previous" buttons or play the slider by clicking the "Play" button.
-
script.js
: This file contains the JavaScript code that controls the image switching in the slider. -
style.css
: This file contains the CSS styling to format the slider and control buttons. -
index.html
: This file is the HTML page that provides the structure of the slider and includes the links to the CSS and JavaScript files.
If you want to add or change the images in the slider, follow these steps:
-
Place your images in the
images
directory. -
Open the
script.js
file. -
Modify the
images
array by adding or removing the desired images. For example:let images = [ "/images/img-1.jpeg", "/images/img-2.jpeg", "/images/img-3.jpeg", "/images/img-4.jpeg", ];
Make sure to adjust the index number used in the
nextImage
andprevImage
functions to accommodate the change in the number of images. -
Save the
script.js
file after your modifications.
If you want to change the style of the slider, follow these steps:
- Open the
style.css
file. - Modify the CSS code to change the appearance of the slider according to your preference.
- Save the
style.css
file after your modifications.
If you'd like to contribute to this project, please open an issue or create a pull request with your changes.
This project is licensed under the [MIT License]